By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,483 Members | 1,449 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,483 IT Pros & Developers. It's quick & easy.

Searching a table for duplicates

P: n/a
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
Share this Question
Share on Google+
2 Replies


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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.