Subform requery not working on form open

krausr79

Registered User.
Local time
Today, 02:16
Joined
Oct 5, 2012
Messages
26
I have a form with two subforms. One subform is a datasheet that pulls data from a temp table. During the other subforms Form_Current, the temp table is emptied (DoCmd.RunSQL "Delete from tblAddRefs"), reloaded with data relevent to the current record, and requeried (Forms("frmEDFP").Controls("tblAddRefs subform").Requery). This works like I want it to...

With the exception of the initial load of the main form. The subform based on a table shows (#Deleted) instead of data. if I step through the code, I can see that the temp table is emptied and repopulated by the time I try to requery the subform. This is still happening during the Form_Current of the other subform, which is successfully running on main form load.

If I requery (Forms("frmEDFP").Controls("tblAddRefs subform").Requery) using a button on the main form once it is loaded, the #deleted data is correctly is replaced by regular data, so it's like the requery in the Form_Current event isn't doing anything during load.

Thoughts?
 
Try; Forms![Parent Form Name]![Sub Form name].Form.Requery
So in your case Forms![frmEDFP]![tblAddRefs Subform].form.requery

I have it as above on a db I use regularly and this works for me, let me know how it goes

HTH
 
That put me on the right track. I wasn't sure where to put your code, so I put it in form_load of the main form, but no dice. I noticed the table with #deleted was clearing up if I clicked in it, which led me to track the run of the code. Form_Load wasn't even running when I opened the form! :P I tried putting the refresh in the main form_open, and that did the trick.
 

Users who are viewing this thread

Back
Top Bottom