Connecting Tech Pros Worldwide Help | Site Map

Chkbox to check for duplicate records

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 10th, 2006, 08:15 PM
d9pierce@mchsi.com
Guest
 
Posts: n/a
Default Chkbox to check for duplicate records

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, 08:25 PM
Hansen
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.