Referencing Subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a mainform frmMainForm and a subform frmSubForm. I want to put record
navigation buttons on the main form to move through records on the subform.
I used the following code for the next button on the mainform

DoCmd.GoToRecord acDataForm, "frmSubForm", acNext

When I click the button, I get an error.

The Object 'frmSubForm' isn't Open.

I have tried a number of variations but to no success. Does anyone have a
suggestion?
 
I have a mainform frmMainForm and a subform frmSubForm. I want to put record
navigation buttons on the main form to move through records on the subform.
I used the following code for the next button on the mainform

DoCmd.GoToRecord acDataForm, "frmSubForm", acNext

When I click the button, I get an error.

The Object 'frmSubForm' isn't Open.

In a sense, it isn't: it's not part of the Forms collection. It's accessible
only by navigating from the mainform through the Subform control. If the Name
property of the Subform control on frmMainForm is in fact frmSubForm (it might
be, but the name of the Subform Control and the form object within that
control may be different), try

DoCmd.GoToRecord acDataForm, "Forms!frmMainForm!frmSubForm.Form", acNext


John W. Vinson [MVP]
 
Hi John
I made sure the control and subform have the same name (frmSubForm). Tried
the code you suggested and still get the error

The object 'Forms!frmMainForm!frmSubForm.Form' isn't open
 
Back
Top