Referencing Subform

N

NevilleT

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?
 
J

John W. Vinson

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]
 
N

NevilleT

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top