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

Prevent redundant data in an SQL database

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I have a database to keep up with clients. If the client is already in the database, I want to add a number to the #Visits column when they enter their information. Their Phone # is the "primary key" so I need to compare that with the information entered on the form. If the Phone # exists in the database I need the #Visits column to be updated with one added to it. Like

.fields("#Visits").value = .fields("#Visits").value + 1

I'm using a reference to ADO 2.5 to open the connection.
How would I go about comparing the Phone# field in code to see if it already exists.
 
This seems pretty straight forward. Create a recordset based on a SQL SELECT for Phone # WHERE Client = the client name you are looking for.

If the recordset.recordcount = 0 then the client does not exist. If it is equal to 1, then the client does exist.
 
That's what I needed. Thanks Every day above ground is a GOOD DAY!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top