DCount to test duplicates is giving error message (1 Viewer)

Srussom

Registered User.
Local time
Today, 09:55
Joined
Apr 10, 2018
Messages
15
Dear All,
I have an input Form called "InputMain" for table "Personal" and a field called [PPMembershipID]. This field is in text format. I want to check for duplicates if a new PPMembershipID entry already exists. I tried the following syntax but gave an error message.

Private Sub PPMemebershipID_AfterUpdate()
If DCount("*", "Personal", "[PPMembeershipID] = '" & Me![PPMembershipID] & "'") > 0 Then
MsgBox "Duplicate Exists", vbOKOnly
Cancel = True

End If
End Sub

The error message i got is "Can not find the filed 'PPMembershipID referred in your expression.

I tried in many ways but can not find the solution

Many thanks for your help

Solomon
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 02:55
Joined
Jan 20, 2009
Messages
12,866
[PPMembeershipID]

It is probably a spelling mistake given that you have used three different spellings in your post.
 

Srussom

Registered User.
Local time
Today, 09:55
Joined
Apr 10, 2018
Messages
15
Thanks for your reply, even if i corrected the miss-spelling to:
Private Sub PPMemebershipID_AfterUpdate()
If DCount("*", "Personal", "[PPMembershipID] = '" & Me![PPMembershipID] & "'") > 0 Then
MsgBox "Duplicate", vbOKOnly
Cancel = True

End If
End Sub

I got a message:
"Database can not find the field PPMembershipID referred in your expression"
 

CJ_London

Super Moderator
Staff member
Local time
Today, 17:55
Joined
Feb 19, 2013
Messages
16,747
Private Sub PPMemebershipID_AfterUpdate()
If DCount("*", "Personal", "[PPMembershipID] = '" & Me![PPMembershipID] & "'") > 0 Then
 

Minty

AWF VIP
Local time
Today, 17:55
Joined
Jul 26, 2013
Messages
10,389
To add to CJ's post if you had used the dot . instead of the bang ! here ;

& Me![PPMembershipID] &

Intellisense would have kicked in and put the correct control name.
 

Srussom

Registered User.
Local time
Today, 09:55
Joined
Apr 10, 2018
Messages
15
Dear CJ_London
Many, many thanks for your time and quick response. I just jumped to a complex assumption with out checking my spellings.

A big thank you again.

Regards
Solomon
 

Users who are viewing this thread

Top Bottom