Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How alter onclick event of code for first time login

I have the following code in an onclick event of a login form.  But I need to alter it so that in the event the user is logging in for the first time they will be taken to a separate form to enter their new login of choice.  Then after they have entered their new login be taken back to the original form to continue.  How do I alter the following code?

'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"
            Me.txtPassword.SetFocus
        Exit Sub
    End If
   
'Check value of password in tblEmployees to see if this matches value chosen in combo box
    If Me.txtPassword.Value = DLookup("Password", "tblEmployees", "[EmployeeID]=" & Me.cboName.Value) Then
       
        myempid = Me.cboName.Value

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("LOCALtblLogin")
            rs.AddNew
            rs!FullName = Me.txtFullName
            rs!EmployeeID = Me.txtLoginID
            rs!DateTime = Now()
            rs!SecurityLevel = Me.txtSecurityLevel
            rs.Update
       
'Close logon form and open splash screen
    DoCmd.Close acForm, "frmLogin", acSaveNo
    DoCmd.OpenForm "frmMainMenu"
    Else
        MsgBox "Password Invalid. Please Try Again", vbCritical + vbOKOnly, "Invalid Entry!"
        Me.txtPassword.SetFocus
    End If

'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!"
        Application.Quit
    End If
           
    DoCmd.Close
   
    DoCmd.OpenForm "frmMainMenu"
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SteveL13

ASKER

Nice!  Thank you.