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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting two fields as a unique combination 1

Status
Not open for further replies.

jmob

Programmer
Jun 21, 2005
58
US
I have "TableB" that contains "idTableB"(Primary key), "descriptionB", "myDate".
The rule I would like to implement is: No two records with the same "descriptionB" and "myDate" should exist. I don't want these to serve as the primary key though. >>I know this may not be "normalized", but it is alright for now. thanks.

I think this is some simple answer of setting the keys up, but I am unsure on how to do it. Thanks.
 
You may create an unique composite index on (descriptionB, myDate)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Create an index with both fields. Next to the primary key icon there should be a lightining bolt. In the first column give the index a name. In the second column list the first field, below it list the second field. Set the property to unique. The two have to be unique, but each one can repeat.
 
I have another question along the same lines. After I have created the unique combination, One of my fields is a date where I use the Now() function. I would like to limit the now to just a short date(10/17/2005).
Formatting the date to a short date only shows the date as short, but actually stores it with the time (e.g. 10/17/2005 12:00PM)
Is there a way to actually get it stored as just a short date.
Thanks again!
 
Use the Date() function instead of Now().

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top