View Full Version : Linking Two Tables


Insomniac
10-04-2005, 02:20 AM
Excuse me for sounding extremely dumb, but I have a question that is really bugging me. I have created a database using two tables. The two tables are called User and Assets. In both tables I have set the primary key to be the field Username. I have also linked these two fields.

I have created a form that is my interface for the database and can add and delete from the table (User). I now want to insert a sub form into my form, that displays the contents of my second table (Assets) and reference's the field Username. Hopefully this will enable me to display my table (User) in the Form, whilst only displaying the relevent data in the subform (Assets) for the particular user.

I'm sorry if this sounds confusing, but I would really appreciate your help ...

:confused: :confused: :confused:

Pat Hartman
10-04-2005, 12:00 PM
UserName is a poor choice for a primary key. An autonumber would be a better choice. In any event, by using the same primary key in both tables, you have created a 1-1 relationship. That means that each person can have only ONE asset. I doubt that that is what you had in mind. Change the primary key of the Asset table to be AssetID. Leave the UserID because that becomes the "foreign key" which links an asset to its owner.