Duplication Verification

Hi,

How can I check the duplication of data in a particular field when trying to update a database.The database I am using is access.
It's in VB5
prasugAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GustavoValdesConnect With a Mentor Commented:
If you have a table named Employees with three fields Code, FirstName, LastName. If you want to know if there is a field that already has the Code '001' then you must do a select, this way:

 SELECT COUNT(*) AS Regs
 FROM Employees
 WHERE Code = '001'

Of course you could make this statement with some string concatenations from VB or you could make a parametrized query to send just the code.

Then if the only field (in the only record) this resultset will have has a value different from 0 then you can be sure there is at least one record with the same code, obviously, if you have a unique index there is only one record with this code.

Hope it helps.
0
 
prasugAuthor Commented:
I am not aN EXPERT NOW.
0
 
InteqamCommented:
just do a little select distinct statement and compare the resulting recordset count with the original count ( i suppose you don't have Null values ) they must be the same if there is no duplications.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
prasugAuthor Commented:
This answer is sufficient.when you try to update a field in the database we have to know whether that particular data is already exisiting in the database or not? what is the code for checking the same.
0
 
InteqamCommented:
try the find method in the record set
or the count of the select where statement
0
 
prasugAuthor Commented:
The above answer is not sufficient for me.
I am not an expert.CAn u please describe it with a sample codes.
when you try to update a field in the
                database we have to know whether that particular data is already
                exisiting in the database or not? what is the code for checking the
                same.
0
 
JShepherdCommented:
Is there a primary key on the field that you want to check?
0
 
InteqamCommented:
for 15 points
you are dreaming
0
All Courses

From novice to tech pro — start learning today.