473,387 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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!!!!!

Mar 10 '06 #1
1 1540
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

Mar 10 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: DD | last post by:
I have a subform on a form In the subform i have a chkBox= and a txtbox= The idea is you Chk and the price $40.00 is automaticly entered into The chkBox has code Private Sub...
2
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
0
by: John | last post by:
Hi all, i've added a checkbox column to my datagrid using template columns, and i added a checkbox to the header for check all and uncheck all functionality. the purpose of this is to allow the...
5
by: Alan Little | last post by:
I have affiliates submitting batches of anywhere from 10 to several hundred orders. Each order in the batch must include an order ID, originated by the affiliate, which must be unique across all...
2
by: msbs48 | last post by:
chkbox 1. i pasted in on the form.. there does not seem to be a caption property.. i saw a couple of examples setting the caption in the from load.. The methods/Events window in the code does not...
2
by: nethravathy | last post by:
Hi, The following table namely elcbtripselect contains 5147 records.I want to know wether this table contains duplicate records or not. I tried with following query 1)SELECT...
2
by: Ranma13 | last post by:
Hello, I have a duplicate record check written in VB for a check in/check out database. Here's the pseudocode, written for the BeforeUpdate property on the form: If DCount(search for records with...
2
by: nomvula | last post by:
hi guys i need some help to duplicate records on my form datasheet: here's the example of my form results: ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual UJ...
1
by: xraive | last post by:
I have a problem with this. Currently I am trying Allen's code and i am not successful. Current Design Table1 (Main Form) TravelID (PK) ApprovedBY EntreredBy BudgetCode ExpenseCode
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.