I have the following code in an onclick event of a command button on a login form but want to alter it so the user has to change their password with the first login. How can this be done?
Here's the current code:
Private Sub cmdLogin_Click()
'Check to see if data is entered into the UserName combo box
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
'Check to see if data is entered into the Password combo box
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
'Check value of password in tblEmployees to see if this matches value chosen in combo box
If Me.txtPassword.Value = DLookup("Password", "tblEmployees", "[ID]=" & Me.cboEmployee.Value) Then
myempid = Me.cboEmployee.Value
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("LOCALtblCurrentUser")
rs!EmpName = Me.cboEmployee.Column(1)
rs!EmpN = Me.cboEmployee.Column(0)
rs!Level = Me.txtLevel
rs!Initials = Me.txtInitials
rs!Approver = Me.txtApprover
'Close logon form and open splash screen
DoCmd.Close acForm, "frmLogin", acSaveNo
MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"