424,303 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,303 IT Pros & Developers. It's quick & easy.

Chkbox to check for duplicate records

P: 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.


Mar 10 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
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

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
do whatever else
end if
End If
End Sub

Mar 10 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.