Error 13 Type Mismatch

  • Thread starter T5925MS via AccessMonster.com
  • Start date
T

T5925MS via AccessMonster.com

Need help solving a type mismatch error on the following code:
Many thanks!

Private Sub Form_BeforeUpdate(Cancel As Integer)
'Limits the number of records allowed
'based on the field FloorProgMaxObservations
If DCount("*", "tblFloorProgAudit", "[AuditID] = _
" & Me.AuditID.Value & "" And _
"[FloorProgCriteriaID] = " & _
Me.FloorProgCriteriaID.Value & "" And _
"[AuditorID] = '" & Me.AuditorID.Value & "'") = _
Me.FloorProgMaxObservations.Value Then
MsgBox "You're attempting to exeed the maximum _
number of observation allowed for this criteria _
set. Click OK and then delete this observation."
Cancel = True
End If
End Sub
 
J

Jeanette Cunningham

The part of the DCount starting at "[AuditID] and finishing at
AuditorID.Value & "'") , needs to be rewritten, more like this

"[AuditID] = " & Me.AuditID & " " _
& "AND [FloorProgCriteriaID] = " & Me.FloorProgCriteriaID & " " _
& "AND [AuditorID] = """ & Me.AuditorID & """"

The above assumes that AuditID and FloorprogCriteriaID are both numbers and
AuditorID is text.

If you have trouble deciphering the quotes, copy and past it into Notepad to
see them more clearly.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
T

T5925MS via AccessMonster.com

You solved the problem...Thanks so much!

Jeanette said:
The part of the DCount starting at "[AuditID] and finishing at
AuditorID.Value & "'") , needs to be rewritten, more like this

"[AuditID] = " & Me.AuditID & " " _
& "AND [FloorProgCriteriaID] = " & Me.FloorProgCriteriaID & " " _
& "AND [AuditorID] = """ & Me.AuditorID & """"

The above assumes that AuditID and FloorprogCriteriaID are both numbers and
AuditorID is text.

If you have trouble deciphering the quotes, copy and past it into Notepad to
see them more clearly.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
Need help solving a type mismatch error on the following code:
Many thanks!
[quoted text clipped - 14 lines]
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top