Duplicates Detect Issue

evanark

Registered User.
Local time
Today, 02:37
Joined
Jan 4, 2013
Messages
69
I am sure there is a thread related to this and I apologize for adding this thread if there is. I am having problem with duplicate detect. I have written a some VBA code to detect if a school name exist in the account table. The problem is I get my error messge ever time I enter a different school name. No matter is the school name is in the table I still get my error message. Am I doing somthing wrong?

Here is my code

If DCount("*", "tblAccount", "[accSchoolName]=[accSchoolName]") > 0 Then
MsgBox "School already exist, please enter an new school name to continue. ", vbOKOnly + vbInformation, "School Already Exist!"
Me.Undo
Me.frmSubSystem.Locked = True
End If
 
I'm assuming accSchoolName is a text field on your form, so your syntax in the DCount is wrong.

Your code:
Code:
If DCount("*", "tblAccount", "[accSchoolName]=[accSchoolName]") > 0 Then
Correct Code:
Code:
If DCount("*", "tblAccount", "[accSchoolName]=[COLOR="Red"]'" & Me.accSchoolName & "'"[/COLOR]) > 0 Then
 
Thanks! It works now. I can't belive I missed that :eek:. I need sleep.
 
Sometimes you're the Louisville Slugger
Sometimes you're the ball
Sometimes it all comes together
Sometimes you're gonna lose it all. Mark Knopfler
:banghead:

As long as you get 'er done.
 

Users who are viewing this thread

Back
Top Bottom