Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subform selected record

Status
Not open for further replies.

lloydmav

Programmer
Dec 13, 2002
7
AU
I have an embedded subform on a form. I also have unbound fields on the main form. What I want to do is select a record by clicking on the recordselector on the subform and then have the selected record deisplayed in the fields on the main form. I have been trying for two days now and still haven't managed it. I don't know what code refers to the selected subform record and how then to select a specific field from this selected record.
Could anyone shed any light on what should be a relatively straightforward event.

Thanks

Lloyd
 
Hi lloyd,

Main form - subform is really a 1 to many or many to 1 relationship.

Usually, 'main' holds the one and the 'subform' displays many records related to the 'one' in the main form.
But, you can have the 'many' on the main form and the 'one' in the subform.

The key to this, is your table design.

tblMain
pk
field1
field2 etc

tblSub
pk
field1
feild2
main_fk

Main has many Sub records.

When you have a main form with tblMain, with a subform with tblSub - when you choose a record in the main form, then the sub records display accordingly.

To change how the form works:
Use tblSub on the main form, and tblMain on the SubForm.
Now, when you change the subform record - the main form record will change.

Look at the 'Link Child/Master' property of the sub-form to link the tables on the forms.

Regards,

Darrylle
"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." AND "A pointer to a solution is better than the solution - you'll remember the solution via a pointer". darrylles@totalise.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top