datatype mismatch error in criteria expression

marvil

Registered User.
Local time
Today, 12:17
Joined
Oct 16, 2013
Messages
24
I am getting a datatype mismatch error in criteria expression
Private Sub lblManageEmployees_Click()
On Error GoTo lblManageEmployees_Error

Dim db As Object
Dim rs As Object
Dim frmName As String
Dim allowedField As String
Dim UserID As Integer
Dim UserRoleID As Integer

UserID = Forms!frmMainMenu!txtTempVarsUserID
UserRoleID = Forms!frmMainMenu!txtTempVarsUserRoleID

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT ALL * " & _
"FROM tblUserPermissions " & _
"WHERE (FK_UserID = '" & CInt(UserID) & "') And " & _
"(Allowed <> '" & CStr("None") & "')")

frmName = rs!FormName
allowedField = rs!Allowed

Call CheckPermissions(UserID, frmName, allowedField, rs)

lblManageEmployees_Exit:
Exit Sub

lblManageEmployees_Error:
MsgBox "There was a problem when submitting the record: " & Err.Description, vbOKOnly Or vbInformation, "Record Not Submitted"

Resume lblManageEmployees_Exit
End Sub
 
If FK_UserID is numeric you wouldn't want the single quotes surrounding the value.
 
Thanks pbaldy

I am a bit frustrated because when I fix one error, up pops the next one. I am a C# coder and struggling to get used to the VBA syntax.

I incorporated your suggestion and it seems to work fine now.
 
I have to say that you and some of the other guys here have given me some very good coding advice over the past two days. Thanks very much for your help. Keep up the good work because people like me really appreciate it.
 
Thanks, I appreciate you saying that. I'm thinking of learning C# (or something new), so I may be on the other side of the equation soon.
 

Users who are viewing this thread

Back
Top Bottom