run time error 3464 "Data Type mismatch"
Could someone please tell me why I'm having this error message? I have below code in the OnOpen event of my form. It is supposed to check the tblAccess table which contains categoryID and user IDs assigned to the categories. It should check the category associated with the current user and match it with the categoryID of the form. Based on this, Grant or Deny access.
However, my login form (frmLogin) has a combo box which has a query as its row source . This query uses tblUser, which has userID, Accesslevel, FName, LName but not categoryID .Dim CatID As Long
Dim lUser As Long
lUser = Forms!frmLogin!cmbUser.Column(0)
CatID = DLookup("CategoryID", "tblAccess", "UserID='" & lUser & "'")
Select Case CatID
Case 450
With Me
.DataEntry = True
.AllowEdits = True
.AllowDeletions = False
.AllowAdditions = True
.AllowFilters = False
End With
Case Else
MsgBox "You are not authorized to view this form"
Cancel = True
End Select
Your help is greatly appreciated