Linking forms using IDs

WillowFae

New member
Local time
Today, 04:27
Joined
Dec 16, 2012
Messages
4
I have a problem. I have two tables which are as follows

tblFormName

  • FormNameID (pk)
  • FormName
tblStudents

  • studentsID
  • Surname
  • FirstName
  • FormNameID (fk)
So, I've created a main form based on tblFormName, and a subform based on tlbStudents. What I want is a drop down box in the main form showing the contents of the FormName field. Then, when you select the form you want, it loads the first student record with that FormNameID in the subform.


I don't want the user to have to select FormNameID in the main form as that is not a meaningful piece of data.



How do I go about doing this?
 
how did you relate these tables together, in your main form how did you link the main form and the subform together.

actually you can set an after update code on the FormName dropdown list, the code can initiate a recordset code to move and find the first Record in your subform holding the FormName, but first you must clear how your tables are related, and if you can attach something can help more to explain that would be much better.
 
The tables are linked together with a one to many relationship on the FormID field. The main and subforms are linked together using the Master and Child fields in the Data Properties. Obviously I can't have FormName as the master and then the fk as the child because the data types are different.

I don't think I can attach anything as I'm a new poster.
 
you can attach its ok if you click on go advanced and then on the bottom you will find another button Manage attachment from there you can attach things if you want.
but now as your data are linked this way then maybe you can do the following,
create a code on your FormName after Update event to store the formID on an Unbound Control in the main form and then Move the focus to your subform and point the cursor at the FormID field and loop a search to match the formID.
if you are not aware of the coding maybe if you attach a small sample of your database i can fix the code and explain it for you step by step, which is the shortest way to do instead of keep posting asking answering which consume more time to finish your issue.
 
Thanks ever so much. I've (hopefully) attached a copy of the database (with dummy data obviously - I don't really teach these students!).
 

Attachments

Users who are viewing this thread

Back
Top Bottom