G
Guest
I am creating a security log in case a user tries to open a form they do not
have access to. (The users should not be able to see the form, but you never
know. I suppose this is just a 'Just in case' messure...)
The code below is supposed to check the user table to see if the current
user has permission to have the form open, but I cannot seem to open this
recordset. I use this exact code in other places in the database with no
problem. Now I get the 'No value given for one or more required parameters'
error. The SQL works and the connection is correct so it must be in the
rst.open, but why?
Private Sub Form_Load()
Set cn = CurrentProject.Connection
Set rst = New ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM tUsers WHERE txtUserID ='" & fOSUserName & "'"
rst.Open strSQL, cn
Dim sqlSecurity As String
userID = fOSUserName()
If rst!lngUserLevel <> 10 Then
MsgBox "You do not have appropriate permission to view this form", vbOKOnly,
"Invaild User"
sqlSecurity = "INSERT INTO
tSecurityLog(txtNTName,lngSecurityNum,dtmDate,dtmTime) " & _
"VALUES ('" & userID & "',1,'" & Date & "','" & Time & "')"
DoCmd.RunSQL "sqlSecurity"
Exit Sub
DoCmd.Close acForm, "fUsers"
End If
End Sub
Thanks in advance!
PJ
have access to. (The users should not be able to see the form, but you never
know. I suppose this is just a 'Just in case' messure...)
The code below is supposed to check the user table to see if the current
user has permission to have the form open, but I cannot seem to open this
recordset. I use this exact code in other places in the database with no
problem. Now I get the 'No value given for one or more required parameters'
error. The SQL works and the connection is correct so it must be in the
rst.open, but why?
Private Sub Form_Load()
Set cn = CurrentProject.Connection
Set rst = New ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM tUsers WHERE txtUserID ='" & fOSUserName & "'"
rst.Open strSQL, cn
Dim sqlSecurity As String
userID = fOSUserName()
If rst!lngUserLevel <> 10 Then
MsgBox "You do not have appropriate permission to view this form", vbOKOnly,
"Invaild User"
sqlSecurity = "INSERT INTO
tSecurityLog(txtNTName,lngSecurityNum,dtmDate,dtmTime) " & _
"VALUES ('" & userID & "',1,'" & Date & "','" & Time & "')"
DoCmd.RunSQL "sqlSecurity"
Exit Sub
DoCmd.Close acForm, "fUsers"
End If
End Sub
Thanks in advance!
PJ