New call-to-action
Results 1 to 6 of 6

Thread: Populate user_id field in crosstab

  1. #1
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Populate user_id field in crosstab

    Hi,

    I have a crosstab built on my a5w page.

    Code:
    tbl = table.open("[pathalias.adb_path]\tbl_issues_log.dbf")
    crosstab.db = "[pathalias.adb_path]\0proj.DBF"
    crosstab.db_dd_delete = .F.
    crosstab.filter = "Issue_type = \""+session.Issue_type+"\""
    crosstab.row = "ISSUE_TYPE"
    crosstab.column = "STATUS"
    crosstab.options = "I"
    crosstab.tabulate = "Issue_type"
    crosstab.code = 2
    tbl.crosstab()
    tbl.close()
    I now need to add a default user_id field which is populated by session.__protected__userid so I can then create a script that deletes the users results after use.

    Can anyone show me how I can add the field USER_ID to the crosstab and populate it with my session.__protected__userid variable?

    Thanks in advance.

    Denis

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Populate user_id field in crosstab

    ....
    ....
    tbl.crosstab()
    tbl.close()
    fields = <<%str%
    User_id,c,20
    %str%

    table.add_fields("[pathalias.adb_path]\0proj.DBF", fields)

    a_tbl = table.open("[pathalias.adb_path]\0proj.DBF")
    update.fields = 1
    update.field1 = "User_id"
    update.expr1 = session.__protected__userid variable
    a_tbl.update()
    a_tbl.close()
    There can be only one.

  3. #3
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Re: Populate user_id field in crosstab

    Hi Stan,

    Thanks for the quick response.

    I moved my crosstab into a dialog AfterValidate which works fine, but after I pasted your code into it i get a Bad Expression Character.

    I did copy your code exactly. Do i need to modify anything to get it to work?

    Thanks in advance.


    Denis

  4. #4
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Re: Populate user_id field in crosstab

    Sorry Stan i missed a bit.

    It accepted the code now.

  5. #5
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Re: Populate user_id field in crosstab

    Stan,

    After attempting to use the code. Thank you.

    I am getting the following error;

    Errors in: event.AfterValidate code:
    Property not found
    session.__protected__UserId variable subelement not found.

    Do i need to place any supporting code around the session variable?

    update.expr1 = session.__protected__UserId variable

    Denis

  6. #6
    Member
    Real Name
    Denis Ahmet
    Join Date
    Jul 2005
    Location
    United Kingdom
    Posts
    988

    Default Re: Populate user_id field in crosstab

    Got it.

    update.expr1 = s_quote(session.__protected__UserId)

    Thanks Stan.

    Denis

Similar Threads

  1. Crosstab Query - Incorrect Field Type
    By mustafasheikh in forum Alpha Five Version 10 - Desktop Applications
    Replies: 5
    Last Post: 11-16-2009, 12:06 AM
  2. Replies: 2
    Last Post: 01-30-2009, 06:14 PM
  3. Populate one field with another on new record
    By Outlaw in forum Alpha Five Version 9 - Desktop Applications
    Replies: 5
    Last Post: 01-12-2009, 12:33 AM
  4. Control Crosstab field names
    By Stephen Williams in forum Archived Wishlist
    Replies: 2
    Last Post: 10-27-2005, 11:06 AM
  5. Populate a field
    By Jerry Hartness in forum Alpha Five Version 4
    Replies: 4
    Last Post: 07-14-2001, 11:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •