Page 2 of 2 FirstFirst 12
Results 16 to 17 of 17
  1. #16
    Summit_IT is offline Advanced Beginner
    Windows 10 Access 2003
    Join Date
    Jan 2019
    Location
    Virginia
    Posts
    47
    Thanks for the help
    Well I figured out what I did wrong. Slap me. LOL.



    I went back to the shared code and started to replace pieces one at a time to make sure the code kept working right. Then I was able to recreate the error. After some soul searching and changes I got it to work. The final Code for the btnlogin was;

    Code:
    Option Compare DatabasePrivate intLogonAttempts As Integer
    
    
    Private Sub Form_Open(Cancel As Integer)
    'On open set focus to combo box
    Me.cboUsername.SetFocus
    End Sub
    
    
    Private Sub cboUsername_AfterUpdate()
    'After selecting user name set focus to password field
    Me.txtPassword.SetFocus
    End Sub
    
    
    Private Sub cmdLogin_Click()
    
    
    'Check to see if data is entered into the UserName combo box
    
    
        If IsNull(Me.cboUsername) Or Me.cboUsername = "" Then
                MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
                Me.cboUsername.SetFocus
            Exit Sub
        End If
    
    
    'Check to see if data is entered into the password 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 tblUsers to see if this matches value chosen in combo box
    
    
        If Me.txtPassword.Value = DLookup("strEmpPassword", "tblUsers", "[lngEmpID]=" & Me.cboUsername.Value) Then
    
    
            lngMyEmpID = Me.cboUsername.Value
    
    
    'Close logon form and open splash screen
            
            DoCmd.Close acForm, "frmLogon", acSaveNo
            DoCmd.OpenForm "frmSplash_Screen"
    
    
            Else
            MsgBox "Password Invalid.  Please Try Again", 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
        
    End Sub

  2. #17
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Glad to see you've got it working
    Please don't ignore my comments about encrypting passwords. Its not that difficult to do
    If you ignore it, you WILL have problems when passwords get hacked
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 10-01-2018, 02:40 PM
  2. Replies: 3
    Last Post: 11-21-2015, 07:02 PM
  3. Replies: 3
    Last Post: 05-15-2015, 04:19 PM
  4. Replies: 0
    Last Post: 03-11-2012, 09:19 AM
  5. Replies: 2
    Last Post: 12-02-2010, 02:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums