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

Avoiding Duplicate Entry in DB 1

Status
Not open for further replies.

dburnham

Programmer
Oct 18, 2001
118
0
0
US
I created a VB6 application that updates an Access DB. There is a system generated serial field to keep track of each record. The user will input a date and an ID number into two different fields. There will be many entries with the same date and many entries with the same ID. I need to figure out how to avoid having the same date and ID entered more than once.

Any and all help is appreciated.

David
 
Make date + ID a unique key and trap the errors. Where do they get the id number from? Hopefully they don't have to guess a good one. Peter Meachem
peter@accuflight.com
 
Why don't you add an actual ID field that is autonumber and can't edited by the user. This is generally what's done.
 
Peter,

Are saying to add a field to the DB Table joining the ID and Date as the contents?

The ID is actually an employee clock number.

David
 
No. The indexes button in Access will let you make an index on more than one field, and make it unique as well. Peter Meachem
peter@accuflight.com
 
Currently they are two different fields, so I'm not sure I understand. Do I convert them into one field?

David
 
Open the table in Access in design. Click the Indexes button ( or View indexes from the menu ).
Tyep something into Index name. Select first field in field name. Select second field on the next line. Click back on the first line and set Unique to Yes. Peter Meachem
peter@accuflight.com
 
Thanks,

It's great to learn something new everyday.

David
 
It's probably great to give someone a star too! Glad to be of help. Peter Meachem
peter@accuflight.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top