Forms and Subforms

  • Thread starter Thread starter Bryan
  • Start date Start date
B

Bryan

Guest
I am trying to create a database in Access 97 with one main form and 5 subforms using Tabs to access the subforms. On one form I have a one-to-one relationship and want to desplay the subform in form view. the relationship is a primary key in the table accosiated with the main form and a foriegn key in the table accosiated with the subform. when I tab to the subform it gives me a new, empty record, rather that the record associated witht the record displayed in the main form. How do I get the subform to display the related record every time? How do I set it up so you can creat a new record in the subform for a record in the main form?
 
The easiest was to solve the problem is to establish an "ID" number field in your subform table and use it as the link to the main form (ie: Link Master/Link Child,). (It sounds as though you may have already done this. If so, proceed to step two.) First, add a new "ID" number field to the table associated with your subform. Second, open up your main form in design view. Move to your subform and pull up the Properties window. You should see both a Link Master and a Link Child field. The Link Master field should contain the ID (primary key) field from the table associated with your main form. In the Link Child field, select your newly created "ID" field from your subform table. Exit and open in form view. That should solve the problem. If not, follow steps one and two, then re-import your subform. The subform wizard should automatically establish the link master and link child. I hope it works!!
 
I'm having this same problem. My Master link is the primary key in the main table for my main form (CustomerID), My Child link is the primary key (ReimbursementID) in the table behind my subform. I have both of these selected. They are both AutoNumber fields, and in my Relationships, this is how they are related. Does anyone know what I'm doing wrong?

[This message has been edited by Melody (edited 12-11-2000).]
 
Melody,
Your Child link field should not be a primary key. It should be a foreign key that relates to your CustomerId. For example in your reimbursement table have a customerid key that is a number value that you use as a child key to your CustomerId key in your customer table.


HTH
BAC
 
Melody, if the "primary" vs. "foreign" thing is confusing, just know that the field type in the child table should not be autonumber (which automatically makes it a primary key) but a regular Number with the size of Long Integer.

Hope this helps.

Dan
 

Users who are viewing this thread

Back
Top Bottom