How to get data from subform to put in mainform

G

Guest

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]
 

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