requery multiple forms on a page

triple6

New member
Local time
Today, 10:50
Joined
Jul 21, 2003
Messages
6
I am attempting to requery 2 of 3 subforms on a main form. I am using VBA with the following code

Dim ctl, ctl1 As Control
Set ctl = Forms!checkprice_design_sales!add_des_prices
Set ctl1 = Forms!checkprice_design_sales!Add_colours_for_the_design

DoCmd.GoToControl ctl.Name
Me.Requery

DoCmd.GoToControl ctl1.Name
Me.Requery

At present it only updates ctl1.name, although it does appear to 'pass thru' ctl without updating the underlying query.

I have switched the code around, and it appears to be limited to updating only 1 subform - is this correct? I have attempted to call another procedure to see if it made any difference by 'splitting' the requeries - this also was not successful.

Thanks muchly
 
I think the problem is that the Me.Requery command is being applied to the main form, not the subforms.

To requery a subform from the main form, use a command like this:
Forms!mainformname!subformname.Form.Requery
or
Me.subformname.Form.Requery
 
you're a gem. Worked brilliantly using your first option.

Many thanks.
 
Whoo. I've been called many things before, but not a "gem". Cool!
 
I tried this and it's not working for me. Am I doing something wrong here? I have a main form and a subform. After entering a new record and clicking the SAVE button, I want the subform to requery.

I inserted the code in the VBA section underneath where the SAVE button code is.

I keep getting an error that says Access can't find the "field".
 
octatyan

I suggest the syntax and/or the control name for your subform may need looking at. example:
if your main form name is alpha, and your subform name is beta, then your synatx will be:

forms!alpha!beta.form.requery

this will then requery the subform.

Hope this helps
 

Users who are viewing this thread

Back
Top Bottom