I currently use login code (see below) in the After Update property of the password field of the login form. In my user table I have a field titled Employee Entry ID that I would like to be used in other screens and queries to limit data to only this user's
data. Is there a way to set this as an active field to be a usable variable in other queries as long as the user is logged in?
Option Compare Database
Option Explicit
Private Sub txtPassword_AfterUpdate()
'Check that User is selected
If IsNull(Me.cboUser) Then
MsgBox "You need to select a user!", vbCritical
Me.cboUser.SetFocus
Else
'Check for correct password
If Me.txtPassword = Me.cboUser.Column(2) Then
'Check if password needs to be reset
If Me.cboUser.Column(3) Then
DoCmd.OpenForm "frmPasswordChange", , , "[UserID] = " & Me.cboUser
End If
DoCmd.OpenForm "frmMainMenu"
Me.Visible = False
Else
MsgBox "Password does not match, please re-enter!", vbExclamation
Me.txtPassword = Null
Me.txtPassword.SetFocus
End If
End If
End Sub