NetTalk Central

Author Topic: Form to Form different record  (Read 2315 times)

Sibuya

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • Email
Form to Form different record
« on: May 02, 2016, 05:36:11 PM »
Hi,

Based on example 24 attached I have a situation in that I have to show SecondForm as a record different from the FirstForm based on new record value resulting from processing some data in FirstForm. I Changed the example 24 adding a field loc:newrec in FirstForm and try to “catch” in SecondForm priming the value of index field record in this case MailboxNumber but no success.

Tried creating a SessionValue ‘loc:newrec’ with a new record to show and call SecodForm as a link from FirstForm as : ‘SecondForm?change_btn=change&_bidv_=' & p_web.AddBrowseValue('FirstForm','MailBoxes', MAI:PrimaryKey,p_web.GSV('loc:newrec')) but no success too.

I think that I didn’t understood how NT “remembers” the file settings that a parent pass to a child procedure (handle).

In real application there's a menu that calls a LoginForm. Login will define customer record then opens a second form with customer's data.

How could I do this?

Thank you.

Cheers,

Marcos

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Form to Form different record
« Reply #1 on: May 03, 2016, 02:27:42 AM »
Hi Marcos,

>> I think that I didn’t understood how NT “remembers” the file settings that a parent pass to a child procedure (handle).

It would be a bad idea to think of this as a parent / child type relationship. Think of it more as a browse, followed by a form, followed by a form. In "concept" the 3 procedures are unrelated.

Now a browse and the first form "fit together" because they are both set on the same Table, with the same "Unique key". So the key field (of the unique key) is included when calling the form. The form can then load that record.

When you go from a Form to another form, then all the fields on Form 1 are in the Value Queue when Form 2 is first called. Not the session queue (because values ar not automatically moved to the session queue) just the value queue.

In your example you have loc:newrec, and this will thus be in the Value queue. The first thing you want to do in the second form is then to store this in the Session queue.

  p_web.StoreValue('loc:newrec')

You can safely do this right at the top of the (second) form procedure.

Then in the preupdate routine you can use p_web.GetSessionValue('loc:newrec')

>> I think that I didn’t understood how NT “remembers” the file settings that a parent pass to a child procedure (handle).

There are really only 2 things in play here. The "Value queue" - which are all the parameters coming in via the actual request (you can see these in the log) and the Session Queue - which are "global" to the session itself. Items are moved from the Value queue to the Session Queue using StoreValue. And then in your code elsewhere you pretty much always want to be using the Session Value.

If you want to load table records, then you can move the fields from the table to the session queue using
p_web.FileToSessionQueue(customers)
and you can move from the session queue to the File record using
p_web.SessionQueueToFile(customers)

When manually reading or writing records from a table you should always OPEN and CLOSE the table yourself. Do not assume the tables are Open (they are usually not open.)  For example;

Access:Customers.Open()
Access:Customers.UseFile()
Cus:Id = p_web.GSV('loc:UserId')
Access:Customers.Fetch(cus:key)
p_web.FileToSessionQueue(Customers)
p_web.SetSessionValue('ThisCustomer',cus:id)
Access:Customer.Close()


Cheers
Bruce





Sibuya

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
    • Email
Re: Form to Form different record
« Reply #2 on: May 03, 2016, 06:03:03 AM »
Hi Bruce,

I stored the value and got this value in PreUpdate routine at Start embed code opening, fecthing, saving to sessionqueue and closing Mailboxes.

For example put in loc:newrec number 5 in FirstForm but SecondForm is still getting the original record 2.

Seems that priming has no effect too.

What the effect on Form have when calling "SecondForm?change_btn=change&_bidv_=' & p_web.AddBrowseValue('firstform','mailboxes',MAI:PrimaryKey) ?

Thank you.

Cheers,

Marcos

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Form to Form different record
« Reply #3 on: May 05, 2016, 11:21:48 PM »