Table constraint

Chunk

Registered User.
Local time
Today, 02:26
Joined
Oct 25, 2004
Messages
64
In Oracle, you can set up table constraints which constrain data accross mutliple attributes/fields. Can you do this in Access?

For example. I have:

OrderLine(orderNum,orderLineNum,[productNum],date)

I dont want to allow for the same product to be put on one order twice. Therefore, (orderNum,productNum) must be unique, but productNum is not a part of the primary key so it can be repeated in every row for all the database cares. :P

How can I set this up.

In Oracle I would do something like:

CONSTRAINT chk_prod CHECK UNIQUE (orderNum, productNum)

Thanks for any help.
 
Access doesn't come with table constraints.
You would need to define a Before Update event on your form, using the DCount function.

RV
 
In Access you'd probably open the table in design view, find the index button (to the right of the primary key button on the toolbar), enter a name for the new index, select the fields, and in the bottom part of the box, set the properties of the compound index.
 

Users who are viewing this thread

Back
Top Bottom