I created a database with restriction to forms for users using a module.
I am getting a "runtime error 3464 data type mismatch in criteria expression" I marked in red where I get the error. Can anyone help me please!
This is the code for the module
Public Function Permiso(sFormName As String) As Boolean
Dim sActiveUser As String
sActiveUser = DLookup("IdUser", "tblActiveUser")
Dim bPermisoFor As Boolean
bPermisoFor = DLookup("Access", "tblUsersPermits", "IdUsers= '" & sActiveUser & "' AND NameForm= '" & sFormName & "'")
If bPermisoFor = False Then
Call MsgBox("You don't have access to view this form" _
, " Contact your admin", vbCritical, "Attention")
DoCmd.Close acForm, sFormName
End If
End Function
this is the code to call the module in each form
Private Sub Form_Open(Cancel As Integer)
Call Permiso(Me.Name)
End Sub
:banghead::banghead:
I am getting a "runtime error 3464 data type mismatch in criteria expression" I marked in red where I get the error. Can anyone help me please!
This is the code for the module
Public Function Permiso(sFormName As String) As Boolean
Dim sActiveUser As String
sActiveUser = DLookup("IdUser", "tblActiveUser")
Dim bPermisoFor As Boolean
bPermisoFor = DLookup("Access", "tblUsersPermits", "IdUsers= '" & sActiveUser & "' AND NameForm= '" & sFormName & "'")
If bPermisoFor = False Then
Call MsgBox("You don't have access to view this form" _
, " Contact your admin", vbCritical, "Attention")
DoCmd.Close acForm, sFormName
End If
End Function
this is the code to call the module in each form
Private Sub Form_Open(Cancel As Integer)
Call Permiso(Me.Name)
End Sub
:banghead::banghead: