Unusual Requery Behaviour

XelaIrodavlas

Registered User.
Local time
Today, 21:38
Joined
Oct 26, 2012
Messages
175
Hi All,

I have a form [FrmPersonnel] which contains a subform [sFrmQuals] showing personnel qualifications.

I also have a third form [QualPopup] which is used to add the qualifications, rather than using the subform itself (I do this because the subform only shows a brief summary, rather than the 40-odd fields).

So QualPopup has an onClose event setup so when the user is done, the subform in the FrmPersonnel will be requeried, and data is displayed with the latest changes. The code looks like this:

Code:
If Me.Dirty Then Me.Dirty = False 'Save Record
Forms!FrmPersonnel!sFrmQuals.Requery
Exit Sub

This works perfectly fine if I go in and change a qualification, or add a second/third, or delete. But for some reason I just can't explain, the requery never seems to work for the first qualification!

For example:
If I enter a new starter onto FrmPersonnel, that's fine. If I then want to add a qualification I click the Cmd Button to open QualPopup, enter the qualification details, and close the Popup... I get no errors and return to the main form... I wait... but nothing shows on sFrmQuals. I then hit f5 on my keyboard and the record appears!

Having hit refresh manually, I can now hit the button again, add a second qualification or edit the first, and the changes show as soon as I close the Popup form.

So the code clearly works, just not for the first qualification. This is utterly baffling, does anyone have a clue why this is happening, or what I can do about it?

Many thanks as always :)
Alex S
 
If the main form is still on the new record it may not be saved when your popup is opened, so the subform won't think it has a valid parent? Possibly ?
 
OK so I think I've found a work around.

I still have no idea why it is happening but it seems setting the focus to an arbitrary control on the ParentForm before running the requery makes it work.

This doesn't explain why it happened but it seems to be an easy fix.

Thanks for reading! :)
Alex
 
I do this because the subform only shows a brief summary, rather than the 40-odd fields.

Forty fields to store qualification information? That statement is ringing my normalization alarm.
 
..
For example:
If I enter a new starter onto FrmPersonnel, that's fine. If I then want to add a qualification I click the Cmd Button to open QualPopup, enter the qualification details, and close the Popup... I get no errors and return to the main form... I wait... but nothing shows on sFrmQuals. I then hit f5 on my keyboard and the record appears!
Where is the Cmd Button placed, on the main form or ..?
What if you save the new data in the main form first, (go to another record and back again)?
Where is the data stored, in the same database, backend, SQL-server?
Try placing a breakpoint in the requery code line and wait a few seconds before you continue the code.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom