NetTalk Central

Author Topic: Priming repeated if returning from a child form  (Read 4774 times)

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Priming repeated if returning from a child form
« on: June 17, 2012, 12:13:30 PM »
For a few years I have been using a child form to collect and process multiple select tagged records for a parent record.   Since updating to 6.31 when Save is clicked on the child form, the preinsert routine on the parent form is called again which clears the parent record and primes it with a new unique ID.  Any changes made to the parent form fields are lost and the processed tag records no longer match the ID of the parent record.

Clicking Cancel on the child form does not trigger preinsert again.  The tagging browse on the child form is irrelevant to the cause,  the preinsert problem happens even if there are no fields on the child form.  Turning on the option to skip priming if field is already set has no affect, because the record is cleared before the condition is tested for.

I have modified the dct and app of Tagging example (web48) to demonstrate the problem.  There is a Test menu with Test Tag item that calls a parent form with a time field that is primed with the current time and a button that calls the child form.  Click Cancel on the child form and the time field on the parent form stays the same; click save and the time field is re-primed with the new time.

Any suggestions for how to avoid calling preinsert more than once?

Many thanks.

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11301
    • View Profile
Re: Priming repeated if returning from a child form
« Reply #1 on: June 17, 2012, 09:57:16 PM »
thanks for the example Casey, but I'm not sure what I'm supposed to be doing to re-create the error.
Can you give me directions please?

there were no data files included with the example, so I used the ones from the shipping set, but I'm not sure what path you want me to take through the app.

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Priming repeated if returning from a child form
« Reply #2 on: June 19, 2012, 08:10:58 PM »
Hi, Bruce

Yes, the shipping data files are all that is needed.   Although there are two new tables in the dictionary each with an ID field and a simple string field, the issue is about inserting a new record so existing data for the new tables is not needed.

To replicate the problem, after compiling and running the modified example app, select Test Tag under the Test menu.  Test Form 1 page appears with a single field primed with the current time by PreInsert.  There is a button to call the child form page, Test Form 2 which has just the Save and Cancel buttons.  Clicking Save returns to Test Form 1 but calls PreInsert again so the record is reprimed with a new time.  Clicking Cancel does note call PreInsert again.

Although it was not included in the example app, calling a Browse from the parent form also triggers PreInsert again on returning.

While the example is fairly trivial, in a real world app the consequences can be substantial.  Not only are some fields reprimed, the whole record is cleared so any entries made before going to the child form are lost, and if child records have been tagged the link to the parent record is lost.

Hope that is a little clearer.

Thanks.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11301
    • View Profile
Re: Priming repeated if returning from a child form
« Reply #3 on: June 21, 2012, 12:25:52 AM »
>> "Clicking Save returns to Test Form 1"

this is a key misunderstanding. On the web pages don't "return" - they only move forward.
so what you have here is form A -> form B -> form A. If you want the second call to form A to behave differently to the first call (and you do) then some more magic is involved. More on this in a moment.

First though, you might want to think a bit about some other possibilities. For example, making Form2 open as a popup means you never leave the first-form page (which makes things simpler). Plus, I think, it makes a more natural interface.

regarding the way you're trying to do it - that would be tricky. There are a number of possible paths for that to go - not least affected by the fact that a form can Insert on Open, or Insert the actual record on the Save. If we wanted to go down that route I'd need to think about it a bit.

cheers
Bruce

CaseyR

  • Sr. Member
  • ****
  • Posts: 448
    • View Profile
    • Email
Re: Priming repeated if returning from a child form
« Reply #4 on: June 21, 2012, 10:15:23 AM »
Thanks, Bruce

I think you may taken me a bit too literally on the 'return' bit.   The popup sounds like a good solution though.

What surprises me is that I have been using the approach of calling a child form for multiple select in dozens of procedures since the early days of NT 4.  It is only since the my last update that it stopped working. Maybe I just lucked into unintended functionality.  I wasn't using popups because the child forms were a little big for a typical popup.  But that is pretty minor consideration.

Thanks again.