Warning if name already exists in database

SteveL13
SteveL13 used Ask the Experts™
on
I'm trying to alert a user if a name already exists in the database.  Something is wrong with this code.  Can someone tell me what it is?  The syntax is wrong in the first line.

    If DCount("*", "Member Table", "MemberFullName = '" & Me.txtMemberFullName & "') > 0 then
        MsgBox "There is already a member in the database with this name.", vbOKOnly
    End If
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
you are missing a " at the end before the closing parentheses

 If DCount("*", "Member Table", "MemberFullName = '" & Me.txtMemberFullName & "'") > 0 then

and perhaps better enclose the table in brackets if you still receive an error

 If DCount("*", "[Member Table]", "MemberFullName = '" & Me.txtMemberFullName & "'") > 0 then

Author

Commented:
I provided the wrong info.  I actually have to check for a duplicate record using first and last name.  Here is my before update code but the warning is not appearing:  (now what am I doing wrong?)

    If DCount("*", "Member Table", "MemberFirstName = '" & Me.txtMemberFirstName & "' AND MemberLastName = '" & Me.txtMemberLastName & "'") > 0 Then
        MsgBox "There is already a member in the database with this name.", vbOKOnly
    End If

Author

Commented:
Never mind. It IS working.  Thanks.  I do have another question closely related but I'll post another topic.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial