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

Newbie - Making sure users follow the rules

Status
Not open for further replies.

techsponge

Technical User
Feb 8, 2006
37
US
How can you ensure a form will not allow duplicate records to be created?

My form has 6 fields that are from table 'tblemployee'. The control names and database field names are the same.

name
DOB
position
hire date/time
pay rate
badge #

When a user enters 'BOB, SMITH' in the name field and '2/8/2006 11:00:00 AM' in the hire date field, if this combination exists in the database do not allow the user to proceed?
 
1) create a composite unique index on (name,hire date/time)
2) in the data entry form play with the DLookUp function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks
I was thinking about the dual PK. The default for hiredate is NOW(), so if I enter the new hire record for 'Bob Smith' hired today '2/8/2006 1:49:00 PM' and then forget that I enetred the record and re-enter next week as 'Bob Smith' and change the hiredate default value to '2/8/2006 8:00:00 AM' the record will still be accepted since the name/hiredate is unique?
 
Use Date() 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
 
I'd like to point out that "create a composite unique index on (name,hire date/time)"

is not the same as "dual primary key".

 
Thanks for the information, unfortunatly my boss wants a hire date and time......he just can't make it easy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top