Access SubForm Issue: Missing a link or relationship or...

Peregrinning

New member
Local time
Today, 12:03
Joined
Mar 17, 2010
Messages
2
Long story short: Created simple Access Database. One table, one form. Not a ton of data.
Boss asked if we could add repetitive fields to each record.
Saw a thread here about subforms. Did some research.
This is for a Clinical Medical Trial. Main form has fields like 'Patient First Name', 'Patient Last Name', 'Hospital', 'Doctor', 'start date', 'length of time' 'case number' etc etc.
As several patients may get multiple doses of a drug I created a subform per the idea I got here.
'Drug', 'Dose', 'Administered'.
Insert the subform into the main form. It looks great and seems to work great. I open the DB, rec#1(mainform) is displayed. Enter Drug/Dose info (subform), enter another dose it creates a new line. So far, so awesome.
But it doesn't tie the records together. If I got to record #2 and come back to #1 it doesn't display the records I just entered in the subform. It is back to "rec #1 of #1" on the subfoirm.
I can see the problem: I go to the table of the subform and the data is all there but there is nothing obvious linking it to a record in the main table.
When I use the wizard to insert the subform it asks "would you like to define which fields link your main form to this form" I can't read the whole line "Show -subform- for each record in -mainform- usi..." is what I get. lol
I tried to define my own but no joy.
I understand the relationship concept but can't seem to make it work. 5 records in the subform should be tied to rec#1 in main form. 4 records in subform should be tied to rec#2 in main form.
I went into relationships and tried to link PRODID in Subform with Record# (Autonumber field) in Main form. Tried using last name to link. None of this seems to work.

Access is not my strong suit if you couldn't tell. Got to be something simple I am missing. Sorry if this is lengthy. Just trying to be as complete as I can.
 
In your doses table add a field that is going to link to the main form's id (so make sure they are compatible). Now in the data type for the new field choose the lookup wizard and go through the steps linking it to the main table.

Now open your relationships window and enforce the relationship by click ing on the join between the 2 tables and choosing enforce referential integrity and cascade update.

Now go back to your main form and try adding the subform again using the wizard and set up the join like you've just created.
 
Really appreciate the help. Trying it now. So far it looks good!
 

Users who are viewing this thread

Back
Top Bottom