Originally Posted by
hinchi1
I have been messing around with my code when the user logs in. I was watching a video by Steve Bishop and found this very informative. I followed the video to the letter and created the code for my login form.
Actually you didn't "follow the video to the letter" or you changed the code. You changed some object names.
Steve Bishop Video
Since you modified the code, what's up with
Code:
Module code
UserAccess = Nz(DLookup("HasAccess", "tblEmployeeAccess", "AccessType=" & TempVars("AccessType") & " AND FormName='" & FormName & "'"), False)
and
TempVars("AccessType") = rs!AccessType.Value
Where/how are they used in your dB???
--------------------------------------------------------------------------------------
(and I have issues with the SB code - the record set was not closed and the rs object was not destroyed - see my code modifications)
How I modified the code:
Code:
Private Sub btnLogin_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("tbl1Employees", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "UserName='" & Me.txtUserName & "'"
If rs.NoMatch = True Then
Me.lblWrongUser.Visible = True
Me.txtUserName.SetFocus
Else
Me.lblWrongUser.Visible = False
If rs!Password <> Nz(Me.txtPassword, "") Then
Me.lblWrongPass.Visible = True
Me.txtPassword.SetFocus
Else
Me.lblWrongPass.Visible = False
DoCmd.OpenForm "frmMain"
DoCmd.Close acForm, "frmLogin"
End If
End If
rs.Close
Set rs = Nothing
End Sub