add record to subform

  • Thread starter Thread starter jacks
  • Start date Start date
J

jacks

I have a main form with a sub form in continuous view. I
created a button on the main form and would like to add a
new record on the sub form when clicked. How would I do
this?
 
To create a new record in code and then display it in the subform, AddNew to
the form's RecordsetClone:

Dim frm As Form
Set frm. = Me.[NameOfYourSubformHere].Form
With frm.RecordsetClone
.AddNew
![SomeField] = "Some text to go here"
![AnotherField] = "whatever it should read"
.Update
frm.Bookmark = .LastModified
End With
Set frm = Nothing


If you don't want the new record saved until the user has entered more
stuff, you would need to set focus to the subform, set focus to a control
within the subform, RunCommand acCmdRecordsGotoNew, and then assign a value
to one or more of the controls.
 
Back
Top