NetTalk Central

Author Topic: Example 23- Browse to Another Form Not Working  (Read 1697 times)

jorgemir

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
Example 23- Browse to Another Form Not Working
« on: January 05, 2011, 12:10:40 PM »
Hi. I'm digging into this example to get a clue on how to use a browse to update a form in another table, but it does not work or it is incomplete. Anyway, how do I can achieve this? I need to use a browse (products) to insert/change/delete a record on anoter table (Order Detail).
Thanks
Jorge

Gordon Holfelder

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
    • Email
Re: Example 23- Browse to Another Form Not Working
« Reply #1 on: January 05, 2011, 12:48:39 PM »
Hello Jorge-

There are probably multiple ways of doing something like this. I've been very successful using "Memory" as the source of the form and using local variables to hold the information to be updated. The following example shows the embeds and code I use:

InitForm / 1 Start = !! Look for delete. This logic gets around the fact that you go through here twice on a delete:
IF BAND(p_Stage, 255) = Net:DeleteRecord
  IF p_web.GetValue('DeleteContactID') = 0
    p_web.SetSessionValue('Loc:RequestAction', '2')
    p_web.SetValue('DeleteContactID', p_web.GSV('AFcon:ContactID'))
    DO Get:ContactValues
    DO Save:ContactValues
  END
END

PostUpdate / 1 Start
DO Save:ContactValues

PreUpdate / 1 Start = !! Prepare for change
IF p_web.GetValue('insert_btn') <> ''
  p_web.SetSessionValue('Loc:RequestAction', '0')
ELSIF p_web.GetValue('change_btn') <> ''
  p_web.SetSessionValue('Loc:RequestAction', '1')
ELSE
  p_web.SetSessionValue('Loc:RequestAction', '-1')
END
DO Get:ContactValues

The loc:RequestAction is a session variable I use to track the request; 0=Insert, 1=Change, 2=Delete. The Get and Save routines are where you retrieve your local values from your db, save your local values back to the db or delete your database row(s). I leave those to your imagination. Start with something simple so that you can get the hang of the flow.

HTH,
Gordon