Creating Relationships

V

vgarr

I am trying to create a one to many relationship between two tables and I
keep getting this message that reads "no unique index found for the
referenced field of the primary table" and I can not create the relationship.
What is causing this error message to come up?
 
K

KARL DEWEY

Open the table in design view and look in the column to the left of the field
name that you say is your primary key. Is there an icon there that looks
like a key?

If there is not key then it is not set as the primary key. Click on the
toolbar icon that looks like a key and save.

If you get an error message saying you have duplicate then run a query to
find the duplicate and delete as necessary so as to be able to set your
primary key.
 
V

vgarr

I have a primary in my tblCalLog table set as a autonumber and in my tblID
the primary key is set as text - can this be the problem?
 
J

John Vinson

I am trying to create a one to many relationship between two tables and I
keep getting this message that reads "no unique index found for the
referenced field of the primary table" and I can not create the relationship.
What is causing this error message to come up?

The fact that you do not have a unique Index (such as a Primary Key)
on the field in the "one" side table that you're using to create the
relationship.

Either make that field the Primary Key by opening the table in design
view, selecting the field, and clicking the "key" icon; or (if you
need to join on a field other than the primary key) set that field's
Index property to a unique index.


John W. Vinson[MVP]
 
D

Douglas J Steele

That shouldn't matter, as long as the foreign key in the child table has the
same type as the primary key in the parent table (if the PK is an
AutoNumber, then the FK should be a Long Integer)
 
D

Douglas J. Steele

You should only get a one-to-one if you've declared the field to be a
primary key in both tables.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)
 
J

John Vinson

It only says one to one, how do I change it to one to many?

Sounds like you're trying to link the Primary Key of the one table to
the Primary Key of the other - don't!

The "many" side table should contain its own Primary Key, and - as a
separate field - a Long Integer field which will serve as the foreign
key, linked to the Autonumber primary key of the parent table.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top