Dcount not working but should

arage

Registered User.
Local time
Today, 23:36
Joined
Dec 30, 2000
Messages
537
If DCount("eventnumber", "newquery", _
"[regionaldirectorcode]= " & glblDirCode) = 1 Then
MsgBox "Your region has already assigned event number " & Me.EventNumber _
& vbCrLf & "Your region's next event number is " & Me.txtNxtEventNum, vbExclamation, "Error"
Cancel = True
Exit Sub
End If

The above does not work even though conditions satisfy all parts of the Dcount function.

I’ve actually put in 2 events with number 9 & the criteria equalling 1300 for both regionaldirectorcode and glblDirCode while testing this function out. Any hints where to look? There’s actually more to this function that works but that part just generates an error message if the eventnumber entered is greater that than the value in an unbound on the form.
 
Try modifying your DCount as below:
If DCount("[eventnumber]", "newquery", _
"[regionaldirectorcode]= " & glblDirCode) = 1 Then
 
I modified my Dcount criteria to be more specific but I am still getting a type mismatch error, runtime err 13. I hate this, I’ve been fighting with this the past 2 days, please help! I’ve looked at all my variable & field definitions & don’t see a problem.

If DCount("[eventnumber]", "newquery", _
"[eventnumber]= '" & Me.EventNumber & "' " And [RegionalDirectorCode] = " & glbldircode & '" And [PromotionType] = "' OA") = 1 Then

Whenever I add duplicate data in the form the above code is supposed to catch it & is followed by an error message, but it never can get past the code above b/c of the type mismatch.
 
This is what is working for me currently.

If DCount("[eventnumber]", "newquery", _
"[eventnumber]=" & Me.EventNumber & " And [RegionalDirectorCode] = " & glblDirCode & " And [PromotionType] = 'OA'") = 1 Then
 

Users who are viewing this thread

Back
Top Bottom