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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking form to a subform

Status
Not open for further replies.

JScannell

Programmer
Jan 9, 2001
306
US
I've been going nuts all afternoon. I've created a form with a subform in Access 2002 db that functionally behaves like another form/subform combination except for the data that is retrieved. the method of selecting is the same.

It doesn't work, so I "googled" designing forms and subforms and found a very nice tutorial that shows the steps. One of the steps doesn't occur for me ant I think it's the one that's the cause of my problem.

According to the tutorial, after choosing the form to insert, you are supposed to indicate the linking columns and then name the subform. I never get the "linking columns" step!! That must be why it doesn't work!!

What I had done earlier was modify the subform's underlying query's criteria to: [Forms]![MainForm]![Employee] at the appropriate spot and assumed that that would tie it in. (I since removed that criteria thinking it would allow the wizard to ask for it)

Any ideas as to what to do??

Thanks in advance,

Jerry Scannell
 
lets assume on the main form you have a field called "employeeID". Employees have lots of clients so there is another table called tblClients with a field called "employeeID_fk". Which is the foriegn key that relates a client to an employee. So you add a sub form clients to the main form. Lets call the subform control "subFrmCtlClients" which contains your "subFrmClients". On the subform control there are the properties
Link Master Fields
Link Child Fields

in your case
Link Master Fields:[employeeID]
Link Child Fields:[employeeID_fk]

now when the employeeid changes on the mainform the subform shows clients with a foreign key to that employee.
 
Adding to MajP's advice I find it easiest to open the main form in design view then drag the subform into it from the form list.

Then just click on the edge of the subform, not the black square, then Properties. Then in the All tab, click in Link Child Fields and open up using the ... at the end to get the link field selector. If there's already a relationship between the underlying tables for form and subform the link fields will appear automatically. Otherwise pick them manually.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top