473,387 Members | 1,771 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.

Duplicate Name Alert

I have a query [qryRecords] with field names [strFirstName] and
[strLastName].
When I access any given record in form "test", I want the user to be
alerted if there is more than one record with the same first name and
last name.
This is different from most posts I've read in that this doesn't happen
upon data entry since my data is imported and already verified.
Duplicate first and last names do legitmately exist in this application
and therefore I simply want to be notified when I access a record that
is such.

I've tried Dlookup and various other code, but it ends up flagging
every record or nothing at all...

Private Sub Form_Current()
On Error GoTo Err_cmdNoDup

If DCount("strLastName" & "strFirstName", "qryRecords") > 1 Then
MsgBox Me![strLastName] & ", " & Me![strFirstName] & " is a Name
Alert."
Else
End If

Exit_cmdNoDup
Exit Sub

Err_cmdNoDup:
MsgBox Err.Description
Resume Exit_cmdNoDup

End Sub

Nov 13 '05 #1
2 3126
Br
Seth wrote:
I have a query [qryRecords] with field names [strFirstName] and
[strLastName].
When I access any given record in form "test", I want the user to be
alerted if there is more than one record with the same first name and
last name.
This is different from most posts I've read in that this doesn't
happen upon data entry since my data is imported and already verified.
Duplicate first and last names do legitmately exist in this
application and therefore I simply want to be notified when I access
a record that is such.

I've tried Dlookup and various other code, but it ends up flagging
every record or nothing at all...

Private Sub Form_Current()
On Error GoTo Err_cmdNoDup

If DCount("strLastName" & "strFirstName", "qryRecords") > 1 Then
MsgBox Me![strLastName] & ", " & Me![strFirstName] & " is a Name
Alert."
Else
End If

Exit_cmdNoDup
Exit Sub

Err_cmdNoDup:
MsgBox Err.Description
Resume Exit_cmdNoDup

End Sub


I went a little further and alerted the user if there was anyone

- same names
- same first name and same first letter of last name
- same last name and same first letter of first name

... in case of spelling mistakes.

I also added a Name Comment field that would be displayed next to the
name in all dropdown selections so people of the same name could be
differenciated.
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 13 '05 #2
This example searches the table for other clients with the same name.
"Other" means a different primary key, assumed to be a numeric field named
ClientID in this example.

Private Sub Form_Current()
Dim strWhere As String
Dim lngCount as Long

If Not (IsNull(Me.strLastName) Or IsNull(Me.strFirstName) Or _
(IsNull(Me.ClientID)) Then
strWhere = "(strLastName = """ & Me.strLastname & _
""") AND (strFirstName = """ & Me.strFirstName & _
""") AND (ClientID <> " & Me.ClientID & ")"
lngCount = DCount("*", "CustomerTable", strWhere)
If lngCount > 0 Then
MsdgBox lngCount & " other client(s) with the same name."
End If
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Seth" <sa******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a query [qryRecords] with field names [strFirstName] and
[strLastName].
When I access any given record in form "test", I want the user to be
alerted if there is more than one record with the same first name and
last name.
This is different from most posts I've read in that this doesn't happen
upon data entry since my data is imported and already verified.
Duplicate first and last names do legitmately exist in this application
and therefore I simply want to be notified when I access a record that
is such.

I've tried Dlookup and various other code, but it ends up flagging
every record or nothing at all...

Private Sub Form_Current()
On Error GoTo Err_cmdNoDup

If DCount("strLastName" & "strFirstName", "qryRecords") > 1 Then
MsgBox Me![strLastName] & ", " & Me![strFirstName] & " is a Name
Alert."
Else
End If

Exit_cmdNoDup
Exit Sub

Err_cmdNoDup:
MsgBox Err.Description
Resume Exit_cmdNoDup

End Sub

Nov 13 '05 #3

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

Similar topics

1
by: marx | last post by:
I have a bit of a problem and any help would be much appreciated. Problem: I have two dropdown list boxes with same data(all data driven). These are used for two separate entries. For every...
3
by: man.shahi | last post by:
Hi all, i have a html page with some javascript functions in a js file linked to it. now, if i create a function in the html page with the same name as one of js functions, how can i call the...
9
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
2
by: news | last post by:
I just upgraded to PHP 4.4.2 on my Slackware 10.2 system. And Apache/mySQL/PHP all work great through a browser. No errors. But when I try to run a PHP script through the command line, which I...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
0
by: Johan P | last post by:
Having just compiled DBG 2.15.1 and trying to use it with PHP (cli) give some some problem. Verions: DBG 2.15.1 PHP 4.4.4 (cli) It works fine compiled with the Apache module but when I try...
9
by: Tom_F | last post by:
To comp.databases.ms-access -- I just discovered, to my more than mild dismay, that some tables in my Microsoft Access 2003 database have duplicate numbers in the "AutoNumber" field. (Field...
0
by: Narendra Gc | last post by:
Hi... I am looking after a lan . I am i am not able to access one particular system , by another one particular system. But from these computers i can access all other systems in my lan and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.