473,320 Members | 2,177 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,320 software developers and data experts.

Searching a table for duplicates

I have a table called Payroll and and form called Application.

When SocialSecurityNo is entered on the form, I want to search Payroll
in the field Social2 for a matching number. If a matching number is
found, I want a message box to appear appear stating Duplicate Number.
I have been using the following code but I can't seem to get it to work
right.

This code is in the after update event of socialsecurityno.

If Not
IsNull(Dlookup("[Social2]","Payroll","[Social2]=[SocialSecurityNo]"))
Then
Msgbox "Duplicate Number"
Else
Date.SetFocus

Any suggestions or maybe a better way of coding this?

Thanks!

Nov 17 '06 #1
2 1056
Do you want to disallow the entry of a duplicate number? Your code should be
in the BeforeUpdate event instead of the AfterUpdate event.

If Not IsNull(Dlookup("[Social2]","Payroll","[Social2]= '" & Me.
SocialSecurityNo & "'")) Then
Msgbox "Duplicate Number"
Cancel = True
End If

Ryker wrote:
>I have a table called Payroll and and form called Application.

When SocialSecurityNo is entered on the form, I want to search Payroll
in the field Social2 for a matching number. If a matching number is
found, I want a message box to appear appear stating Duplicate Number.
I have been using the following code but I can't seem to get it to work
right.

This code is in the after update event of socialsecurityno.

If Not
IsNull(Dlookup("[Social2]","Payroll","[Social2]=[SocialSecurityNo]"))
Then
Msgbox "Duplicate Number"
Else
Date.SetFocus

Any suggestions or maybe a better way of coding this?

Thanks!
--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via http://www.accessmonster.com

Nov 17 '06 #2
Thanks! I will give this a try.
ruralguy via AccessMonster.com wrote:
Do you want to disallow the entry of a duplicate number? Your code should be
in the BeforeUpdate event instead of the AfterUpdate event.

If Not IsNull(Dlookup("[Social2]","Payroll","[Social2]= '" & Me.
SocialSecurityNo & "'")) Then
Msgbox "Duplicate Number"
Cancel = True
End If

Ryker wrote:
I have a table called Payroll and and form called Application.

When SocialSecurityNo is entered on the form, I want to search Payroll
in the field Social2 for a matching number. If a matching number is
found, I want a message box to appear appear stating Duplicate Number.
I have been using the following code but I can't seem to get it to work
right.

This code is in the after update event of socialsecurityno.

If Not
IsNull(Dlookup("[Social2]","Payroll","[Social2]=[SocialSecurityNo]"))
Then
Msgbox "Duplicate Number"
Else
Date.SetFocus

Any suggestions or maybe a better way of coding this?

Thanks!

--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via http://www.accessmonster.com
Nov 17 '06 #3

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

Similar topics

3
by: imani_technology_spam | last post by:
We were trying to remove duplicates and came up with two solutions. One solution is similar to the one found in a book called "Advanced Transact-SQL for SQL Server 2000" by Ben-Gan & Moreau. This...
1
by: lost | last post by:
sorry for the basic question, but: I have users entering a serial number on a form in a text box that is bounded and called via a query. Prior to allowing that number to be entered into the...
2
by: Rich Lussier | last post by:
access 2000 newbie here - I need to create a new table (make-table query) selecting from the following fields in a table: netname | IP_address | port_number | status | connection The...
5
by: Jermin | last post by:
Hi, I have a database composed of a single table composed of 2 columns, an auto-numbered ID column and a column which contains 30 million random numbers. All I want to Access to do is check the...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
3
by: AK | last post by:
Hi Our product uses MS-SQL Server 2000. One of our customer has 10 installations with each installation stroring data in its own database. Now the customer wants to consolidate these databases...
4
by: Killer42 | last post by:
Hi all. Sorry, this is probably a really simple one but I'm having some difficulty with it, and don't have much time to devote to it right now. I need to find all the records which have...
7
by: john | last post by:
In my form I have a master table and a details table linked 1xM. I can search through the whole parent table but I also like to be able to search through the child table fields to find parent...
0
by: cannonpm | last post by:
Greetings and salutations. I have developed an A2K3 MDB and have a search form modeled after Allen Browne's search form (http:// allenbrowne.com/ser-62.html). It works well except for records which...
8
natalie99
by: natalie99 | last post by:
hi everyone i have reseached this topic and cannot seem to find a solution that suits my problem, please help!! I have two tables, "Inventory" which contains 30,000 or so records, with about...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.