Connecting Tech Pros Worldwide Help | Site Map

Chkbox to check for duplicate records

  #1  
Old March 10th, 2006, 09:15 PM
d9pierce@mchsi.com
Guest
 
Posts: n/a
Hi all,
I have a company form that I would like to protect against duplication
unless checked. Main point being, that I dont want to just be able to
add a duplicate company name in a test box unless I need that for some
reason, which there are reasons. I need a bound or unbound check box
that would be clicked to cheeck for duplicate records once i type in a
company name and leave that field. I need this to be able to view that
company information and let me decide to add a second company to the
table with the same name.

Example: I have 30,000 subcontractors and when i obtain a new one I
want to enter their information in it my data and have a cheeckbox
where I can enable to check the table for existing company with that
name and let me know I all ready have this company. I also need the
option to un-check this as sometime I run into a subcontractor that has
more than one work scope under the same name, so I would need to add
that company twice.

Any HELP PLEASE!!!!!

  #2  
Old March 10th, 2006, 09:25 PM
Hansen
Guest
 
Posts: n/a

re: Chkbox to check for duplicate records


In the AfterUpdate event of the textbox, do a if statement to check if
the checkbox has been checked and based on that result see if you get a
recordcount greater than 0 for the selection out of the table with
company information where the company name equals the value of the
textbox.
Example:

Dim dbs as Database
Dim rst as Recordset
Dim qry as String

set dbs =opendatabase()
If CheckBox.value = -1 Then (If you want to check duplicates)
qry = "Select * from tblcompany where companyname = " &
(Textbox.value) &""
set rst = dbs.openrecordset(qry, dbopendynaset)
If rst.recordcount = 0 (meaning there are no
records that match)
do whatever
Else
do whatever else
end if
End If
End Sub

Closed Thread