Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigating subform with VBA

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
I have a mainform whose data source is linked to a table called 'PARENT'
I have a subform whose data source is linked to another table called 'CHILD'(in the Database Window->Forms) and named as subFrmChild
The records in the parent and child are linked together.

I have a button in the main form that would find a record in the main form, and add a new record in the subform.

I am having trouble adding new record in the subform with codes like the following:=
Code:
DoCmd.GoToRecord acDataForm, "child", acNewRec

This gives me an error saying that the form "child" is not open!

I tried replacing "child" by "subFrmChild", and then it gives me a similar error.
Code:
Forms!Parent!subFrmChild
or
Code:
Forms!Parent!child
doesn't work either with or without the ""

Any suggestions as to how to do what I want to do?
 
Yeah, I've got a similar problem.
On the child subform I have:

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
End Sub

This works fine when you open just this form, but doesn't work with the main form.
I have substituted me.name for the actual subform name but still get the same error:

The object 'Child' is not open.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top