Restricting Data in fields

S

Stephen Brown

I have a table with a number of fields that have associated listboxes to
Lookup values for the fields from other tables.

However, this doesn't appear to stop other values being entered in the field.

How can I restrict the possible values of the field so that it has to be one
of the values from the list?

Thanks
 
A

Allen Browne

1. Open the Relationships window (Tools menu).

2. Add the main table, and also the lookup tables.

3. If you do not see lines joining them, then drag the main table field onto
the appropriate lookup table's field. Access pops up a dialog to confirm the
relationship. In that dialog, check the box for Referential Integrity.

This will prevent entering a value in the main table's field that does not
exist in the lookup table's field.
 
S

Stephen Brown

Thank you for your suggestion.

I have tried setting up the relationships as you explained. I can create
the link but when I click on the "Enforce Referential Integrity" box I get
the error message "No unique index found for the referenced field of the
primary table".

I don't understand what that means. Any suggestions?

Thanks


Stephen Brown
 
A

Allen Browne

You need to create a primary key index (or at least a unique index) in your
lookup table.

For example, open the Northwind sample datatbase, and look at the
relationship between Products and Categories. CategoryID is the primary key
of the Categories table. As a result, they can create a relationship to the
CategoryID field in the Products table, and use Relational Integrity.
 
Top