How to get data from subform to put in mainform

N

Nova

I have mainform (single form) and subform (data sheet), same fields of both
forms.
When I open form in edit mode, I want to get data record is selected in
subform to show on mainform to edit data. How can I do?
 
D

Duane Hookom

Use a single form subform on the main form rather than binding your main
form. You can add a text box to the main form:
Name: txtPrimaryKey
Control Source:

Then in the On Current event of the datasheet subform, add code like:
Me.Parent.Form.txtPrimayKey = Me.PrimaryKeyField

Then set the Link Master/Child of the single form subform to
Link Master: txtPrimaryKey
Link Child: [PrimaryKeyField]
 
Top