Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make two fields being UNIQUE

Status
Not open for further replies.

jurki

Technical User
Jun 3, 2003
2
BE
Hello everybody,

Here is my question,

Is it possible in acces such as in Oracle to define that the combination of two field is unique?

I know that's possible if the two fields are defined as the primary key of the table, but is it possible with two "classic" fields?

Thanks
 
I don't know what you mean by "unique" but you can create expressions based on several fields:

EXPR = [Field1] & " - " & [Field2] ' if text

EXPR = [Field1] + [Field2] ' if numeric, using any math syntax.

Maybe you can explain what you're trying to do with "unique" and I'll understand better.


Jim DeGeorge [wavey]
 
jurki

This is done at the table level. Open the table in design mode.

There are two ways of doing this.

If this is to be the primary key, select the first key, then with the mouse, CTL-left-click the second field. Still holding down the CTL key, now right click to being up a menu, and select primary key. Both fields should now depict the key symbol indicating them to be the primary key.

The alternate way, and if these fields are not the primary key.

Click on the indexes icon which becomes available when in tabe design mode. (Should be left of primary key icon, listing squiggle on left side, and lighting bolt on right side.) Can also select under the View menu option.

This will open up your indexes setup.

Enter a description or index name, say UniqueKey, enter the first key field. Then without entering a description, enter the second field on the second line. Go back to the first field, and then tweak per your requirements - primary, unique, ignore nulls.

Using this method, you can actually add a third or more fields if trying to optimize a query.

Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top