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

Thread: Fieldrule function wanted to get name of open table for update field

  1. #1
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Fieldrule function wanted to get name of open table for update field

    Hi all,

    Is there a way to create a function which can be called by a fieldrule for a conditional update of one or more fields in the current table?

    Can this function thus be used by other tables with identical fieldnames?

    I tried to accomplish it with the help examples of <TBL>.FILENAME_GET()

    Code:
    dim tbl as P
    tbl = table.current()
    tbl2 = table.open(tbl.filename_get())
    and
    Code:
    dim tbl2 as P
    tbl2 = table.open(table.current().filename_get())
    but struggle with the syntax.

    Who can help me with this function?

    The workaround is to add Xbasic to the fieldrule (Record Events: CanSaveRecord) for every table with its own tablename in it.

    Ton

  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: Fieldrule function wanted to get name of open table for update field

    What is a conditional update? An update operation? A script which updates records in a table?
    There can be only one.

  3. #3
    VAR
    Real Name
    Bill Parker
    Join Date
    Apr 2000
    Location
    Dallas, TX
    Posts
    1,734

    Default Re: Fieldrule function wanted to get name of open table for update field

    Ton,

    This should work. Are you getting an error?

    If this is ever a set then there are other things you must do.

    Bill.

  4. #4
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: Fieldrule function wanted to get name of open table for update field

    Stan

    The update of a field in the same table depending the value of a variable.



    Bill,

    I tried also in the interactive window with an open table.
    I added a pointer to table.current() but could not get the filename but don't know why, it is not in a set


    Ton

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

    Default Re: Fieldrule function wanted to get name of open table for update field

    Ton,

    The name of tbl.current() in the interactive is _NUL_ unless you reset the session table.

    ? table.current().name_get()
    = "_NUL_"
    tbl = table.open("customer")
    tbl.reset("customer")
    ? tbl.current().name_get()
    = "customer"
    Notice, you probably want .name_get() instead of .filename_get().
    Last edited by Stan Mathews; 09-21-2009 at 02:07 PM.
    There can be only one.

  6. #6
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: Fieldrule function wanted to get name of open table for update field

    Stan and Bill,

    This is indeed what I get

    Code:
    dim tbl2 as P
    tbl2 = table.open(table.current().filename_get())
    Error loading <NUL>: NULL table does not support 'db_alias_put' method.


    What I wanted to accomplish is a function that for example updates a field called inputdate in misc tables. As said it is called by a fieldrule.
    But... with a tbl.reset command I must hardcode the filename.

    When update a field you must point to customer->date because 'date' is a unkown variable thus results as an error.

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

    Default Re: Fieldrule function wanted to get name of open table for update field

    I tried this on a button on the AlphaSports Customer Information form.

    Code:
    tbl = table.current()
    name = tbl.name_get()
    tbl2 = table.open(name)
    name2 = tbl2.name_get()
    ui_msg_box("opened",name2)
    See screenshot for result. Note that Alpha "aliases" the second open instance with a postpending digit.

    You can, obviously, get the actual table name with

    left(name2,-1)
    Last edited by Stan Mathews; 09-21-2009 at 02:23 PM.
    There can be only one.

  8. #8
    VAR
    Real Name
    Bill Parker
    Join Date
    Apr 2000
    Location
    Dallas, TX
    Posts
    1,734

    Default Re: Fieldrule function wanted to get name of open table for update field

    Ton,

    t = table.open("contact")
    ?t.filename_get()
    = "d:\a5v5\helps intl\helps08\contact.DBF"
    vFilename = t.filename_get()

    t2 = table.open(vFilename)
    ?t2.filename_get()
    = "d:\a5v5\helps intl\helps08\contact.DBF"

    t2.close()

    Bill.

  9. #9
    Member Ton Spies's Avatar
    Real Name
    Ton Spies
    Join Date
    Apr 2002
    Location
    Leeuwarden, The Netherlands
    Posts
    555

    Default Re: Fieldrule function wanted to get name of open table for update field

    I was not on the right way, thinking that using the tablename was a must, as you do in the fieldrules: customer->lastname = my_name.

    Searching in the forum I found some examples about opening a current table and using the pointer like this: tbl.lastname = my_name.

    So I just finished my function the way as advised by Cal already in 2005 where he also did not use 'change_begin()' and 'change_end()'.

    Thanks Stan and Bill for jumping in so quick.

    This is a great forum I've learned a few nice things today.

    Ton

Similar Threads

  1. Can't update a value for a field in a child table
    By chuck in forum Alpha Five Version 8
    Replies: 0
    Last Post: 04-07-2007, 11:44 AM
  2. Maximum fillin fields of table lookup(fieldrule)
    By B.B.Bongers in forum Alpha Five Version 7
    Replies: 10
    Last Post: 04-02-2007, 10:04 AM
  3. Memo field in Grid with update function
    By dchiass in forum Web Application Server v7
    Replies: 11
    Last Post: 02-03-2007, 12:14 PM
  4. Newbie, field update from other table field
    By Peder Lundstrom in forum Alpha Five Version 5
    Replies: 1
    Last Post: 05-07-2004, 04:49 AM
  5. Window open list wrong after table update
    By JerryBrightbill in forum Alpha Five Version 4
    Replies: 3
    Last Post: 05-03-2000, 04:23 AM

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
  •