DCount Type Mismatch Problem

  • Thread starter Thread starter esi
  • Start date Start date
E

esi

Trying to use the following code but keep getting a type mismatch error. My
[Counted] field is a yes/no field

Dim stDocName As String

stDocName = "UploadMacro"

If DCount("*", "DrugTemp") = DCount("*", "DrugTemp", "[Counted]=True")
Then
DoCmd.RunMacro stDocName
Else
MsgBox "Please be sure that all items have been counted before
uploading", "vbOKOnly","Error"
End If
 
vbokonly should not be in quotes: it is a built-in numeric constant.

esi, when you quote an error message, please say what line it occurs on.
You< know that - we do not.

HTH,
TC


esi said:
Trying to use the following code but keep getting a type mismatch error. My
[Counted] field is a yes/no field

Dim stDocName As String

stDocName = "UploadMacro"

If DCount("*", "DrugTemp") = DCount("*", "DrugTemp", "[Counted]=True")
Then
DoCmd.RunMacro stDocName
Else
MsgBox "Please be sure that all items have been counted before
uploading", "vbOKOnly","Error"
End If
 
Try wrapping both DCounts in NZ
NZ(Dcount(...),0")
This will get rid of Nulls



Trying to use the following code but keep getting a type mismatch error. My
[Counted] field is a yes/no field

Dim stDocName As String

stDocName = "UploadMacro"

If DCount("*", "DrugTemp") = DCount("*", "DrugTemp", "[Counted]=True")
Then
DoCmd.RunMacro stDocName
Else
MsgBox "Please be sure that all items have been counted before
uploading", "vbOKOnly","Error"
End If
 
Back
Top