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

Duplicate data

Status
Not open for further replies.

asmall

Programmer
Dec 26, 2002
31
US
I have a database where if someone types in a number and that number already exist in the database I want code to search the table, find the that same number and show a message box saying that number already exists. Is this possible? I hope I'm making sense
 
On the field you want no duplicates change its properties (Indexed) in the table to 'Yes (No Duplicates)'. This will then not allow duplicate entries.
 
It's very possible! It's called a parameterized query. You can pass the parameter to a select query in a couple of ways. One is to have the query pick up a value in a text box, combo box, etc or have the user type in the value when the query executes.

Another way to check if a vaslue is in your table is to set up your index as unique, with no duplicates. That is. when the user enters data for a new record, a msg will pop up warning the user that the value already exists and duplicates are not allowed.
 
The user is entering new data in unbound textboxes. The textbox I am validating is the "TagID" textbox. I have SQL code behind a Save button, and if the TagID matches what's in the table, I get a message saying the records cannot append.
 
The user is entering new data in unbound textboxes. The textbox I am validating is the "TagID" textbox. I have SQL code behind a Save button, and if the TagID matches what's in the table, I get a message saying the records cannot append.

By the way, the TagID is the primary key!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top