requery subform from another subfrom

HarrySpencer

Registered User.
Local time
Today, 04:45
Joined
Apr 10, 2007
Messages
25
Hi,

have found a lot of info on similar subjects but can't get the syntax right.

I have a main form (MainPage_fm) this has about 7 subforms (same level all placed in a tab control)

I'm trying to requery a subform from another subform, my guess is I need to refer to the parent form and then to the subform I want to requery but can't get the syntax right I'm getting errors that the say can't find field or form I'm refering to have tried about 10 variations of the code below without luck. please can someone help me :(

Forms!Parent!CRBArchive_tb_cfm.Requery
Forms!MainPage_fm!CRBArchive_tb_cfm.Form.Requery

also found this link which has been very helpful for other tasks but not this time thought others might find it as helpful
http://www.mvps.org/access/forms/frm0031.htm
 
To requery a subform from a subform, you would use:
Code:
Forms!YourMainFormNameHere.YourSubformCONTAINERNameHere.Form.Requery

Remember that the subform container name is the name to use, and it can be the same as the subform name, but it might not be also.
 
i had changed the container name, thank you very much Bob
 
I've looked closely at this and a hundred other threads on requerying subforms, but have not yet found the answer to this question. Hope someone can help!

I have a main form: frmSelPrint, which contains two subforms in datasheet view: sbfrmPlantName and sbfrmPlantPrint. Ticking a checkbox on sbfrmPlantName should then cause that record to appear in sbfrmPlantPrint. The code I ahve in the AfterUpdate event of the checkbox on sbfrmPlantName is


Forms!frmSelPrint.sbfrmPlantPrint.Form.Requery

And this kind of works. The sbfrmPlantName oes refresh, but only after TWO boxes have been ticked. Also, if you tick some and then untiock, it will take two unticks to get the form to refresh. What's going on here?
 
Too big to post here, please excuse the otherwise WIP nature of it:
(Access 2000 database) Link
Re-uploaded database (to same url) with easier to understand processes at 2.43pm GMT. You may find the newer version of frmSelPrint easier to work with!
 
Last edited:
Okay, simple problem. When you check the checkbox the record hasn't saved yet so it won't show up with a requery. Just change your checkbox's after update event code to this:

Code:
    If Me.Dirty Then Me.Dirty = False
    Forms!frmSelPrint.sbfrmPlantPrint.Form.Requery

and that will do it for you.
 
Brilliant, thanks very much!
Should have thought to try that as i saw similar code elsewhere on another thread!
 
GladWeCouldHelp.png
 

Users who are viewing this thread

Back
Top Bottom