问题
First I want to say that I'm a beginner in Access, and I will appreciate every bit of help I can get.
I have created a form showing records from one of my tables with three subforms. The record and the subforms has a one-to-many relationship. I am now creating buttons for each of the subforms for creating new records in the subforms.
I've managed to make the buttons and used the Macro builder to open the forms in a dialog mode with Add as data mode.
Openform (New recordSub1; Form; ; ; Add; Dialog)
But the users has to manually add the ID of the parent in order to keep the relationship between the parent and the child record. How can I bring the ID of the parent record over to the form which opens when the users click on the "Add new record" button for the subforms?
Thanks!
回答1:
With Me.MySubForm.Form.RecordsetClone
.AddNew
!data = Your data
!ID_MySubForm = Me.ID
.Update
End With
来源:https://stackoverflow.com/questions/22415770/new-record-in-subform-based-on-id-of-main-form