Minimize/Maximize Part 2

Hi, here I am again! [:p] I tried Jack’s suggestion and it works fine until… let’s try an example: I have this form with a tablebox on the left side showing 5 records Property 1 | Specific Weight Property 2 | Resistivity Property 3 | Flammability Property 4 | Visual check Property 5 | Water Absorption When the focus is on Property 1 on the right side you can see: Unit Of Measure Gr/M3 Minimum 0,35 Maximum 1,5 When the focus is on Property 3 (Flammability) on the right side you see: Unit Of Measure CODE Code V1 When the focus is on Property 5 on the right side you see: Unit Of Measure % Minimum 0,3 Maximum 0,5 OK? Now let’s set the focus on Property 3 and press the button which opens the Comments Sheet, enter some comments and close the Comments Sheet. On the property form the cursor is still on the Property 3 line, but the right side looks like this: Unit Of Measure CODE (UM of Property 3) Minimum 0,3 (Values of Property 5) Maximum 0,5 That happens every time a second form is run and closed (even a message box) and the tablebox is reloaded having the code in the AfterGetRecord trigger executed for each record and stopped on the last one. [xx(] How can I correct this? Anna

Hi Anna! Did you try and put the code into the OnAfterGetCurrRecord trigger instead?

Hm, I just tried a bit and found that even after opening and closing another form, the OnAfterGetRecord and OnAfterGetCurrRecord triggers are executed for the current record only. So, why does your form execute OnAfterGetRecord for all records? And why is the Unit of Measure correctly from the current record and not from the last one?

quote:


Originally posted by xorph
Hm, I just tried a bit and found that even after opening and closing another form, the OnAfterGetRecord and OnAfterGetCurrRecord triggers are executed for the current record only. So, why does your form execute OnAfterGetRecord for all records? And why is the Unit of Measure correctly from the current record and not from the last one?


I don’t know. CTRL+F8 Shows the current record and it has nothing in Minimum and Maximum. What I did understand is that the VISIBLE properties are set according to the last record content. I assumed that was due to the fact that tha last OnAfterGetRecord trigger was executed on the last record. Anyway, I’ve tried with OnAfterGetCurrRecord and it seems to work. [:)] That solves the problem for now. I’ll puzzle about the hows and whys later. [}:)] Anna

Hm, maybe there’s a problem with the code which sets the VISIBLE property? When the form opens, OnAfterGetCurrRecord is executed for the current record, and then OnAfterGetRecord is executed for each record in turn. Later, when a new record is selected or the form refreshed due to another form closing, these triggers are only executed for the current record. If some controls were set to VISIBLE=TRUE for the last record in the initial pass through all records, but never reset to VISBLE=FALSE, they would just stay there. Just a thought…

quote:


Originally posted by xorph
Hm, maybe there’s a problem with the code which sets the VISIBLE property? When the form opens, OnAfterGetCurrRecord is executed for the current record, and then OnAfterGetRecord is executed for each record in turn. Later, when a new record is selected or the form refreshed due to another form closing, these triggers are only executed for the current record. If some controls were set to VISIBLE=TRUE for the last record in the initial pass through all records, but never reset to VISBLE=FALSE, they would just stay there. Just a thought…


I don’t think so, but I’ll check. How did you you test it? My form is used as a subform, which might cause a different behaviour. Actually, I’ve seen in debug the records in the tablebox being reloaded, after the other form was closed. That might be caused by some stupid thing I’ve done, of course, but I can’t get at it, yet. [B)] Anyway, I’ve follewed your suggestion to move the code setting the VISIBLE properties into AfterGetCurrRecord trigger and it worked. [:D] BTW - Every time the VISIBLEs are set, they are all turned off first. Anna

quote:


Originally posted by Anna Perotti
I don’t think so, but I’ll check. How did you you test it?


I simply put a MESSAGE(…) into the triggers. Then I put a FORM.RUNMODAL(…) into the OnAfterValidate trigger of some field to test the behaviour when a form pops up and gets closed again. The subform thingy could actually be the cause of the problem. When the current record on the main form is refreshed, the system will probably reload the entire subform for this record. I will try this and report back to you [:D]

Anna, it is as I had suspected. When you have a subform, then pop up and close another form from the main form, and then (important!) do a REFRESH on the main form (in code just after the RUNMODAL), the entire subform is reloaded, causing all the OnAfterGetRecord triggers to fire (as well as OnAfterGetCurrRecord for the current one). Without the refresh, nothing happens at all.