Adding new records to subforms

J

Jess

I have a form (mainform) with one subform: subform1 (subform1Name,
subform1ContainerName). Subform1 has another subform: subform2 (subform2Name,
subform2ContainerName)

How can I add a new record to subform1 and subform2 if I am in another form,
formx?

Thanks
 
M

Marshall Barton

Jess said:
I have a form (mainform) with one subform: subform1 (subform1Name,
subform1ContainerName). Subform1 has another subform: subform2
(subform2Name, subform2ContainerName)

How can I add a new record to subform1 and subform2 if I am in
another form, formx?

In a copy of your database, try an experiment like:

With Forms!mainform.subform1.Form.Recordset
.AddNew
!thisfield = somevalue
!thatfield = anothervalue
. . .
.UpDate
End With

With Forms!mainform.subform1.Form.subform2.Form.Recordset
.AddNew
. . .
.UpDate
End With
 
M

Marshall Barton

You might(??) be able to do it using DoCmd.RunSQL to execute
a Append query, but it could take a lot of code to create
the query or maybe some other mechanism based on details
about the information you want in the new records.

Based on what what you posted, I believe the code om my
earlier reply is the easiest way to do what you asked.
 

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