Results 1 to 4 of 4
  1. #1
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183

    Problem with User Login and Password

    So I have this form which will ask for User Login and Password for all users before entering in to the database.



    Some where my code went wrong and I can't seem to figure it out.

    Here is the code under Login Click:

    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"
                Me.cboEmployee.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 tblEmployees to see if this matches value chosen in combo box
    
      If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", _
      "[lngEmpID]=" & Me.cboEmployee.Value) Then
      lngMyEmpID = Me.cboEmployee.Value
    
    'Close logon form and open splash screen
            
            DoCmd.Close acForm, "frm_main", acSaveNo
            DoCmd.OpenForm "frmMainMenu"
    
            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

    The above code keep saying:
    Code:
    Run-time error '2471': The expression you entered as a query parameter produced this error: 'rgp1'

    The line in blue is the error line.

    Please help

    Thank you

  2. #2
    dreday's Avatar
    dreday is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    58
    Sounds like the value of cboEmployee.value is the incorrect format to match against lngEmpID. Are you sure your combobox is returning an integer and not text?

  3. #3
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by dreday View Post
    Sounds like the value of cboEmployee.value is the incorrect format to match against lngEmpID. Are you sure your combobox is returning an integer and not text?

    Sorry, I did not understand what you meant. You mean in the properties I should format it to an integer?

  4. #4
    sk88 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    183
    Quote Originally Posted by dreday View Post
    Sounds like the value of cboEmployee.value is the incorrect format to match against lngEmpID. Are you sure your combobox is returning an integer and not text?

    actually never mind. I got it fixed. You were right about the combo box. I recreated the combo box and now it is working fine.

    Thanks DREDAY!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 11-23-2011, 08:24 AM
  2. Replies: 3
    Last Post: 09-22-2011, 03:35 PM
  3. Display user's database or record after login
    By stoey in forum Programming
    Replies: 13
    Last Post: 09-15-2011, 11:18 AM
  4. Login/Password Code not working
    By eww in forum Programming
    Replies: 3
    Last Post: 09-21-2010, 10:49 AM
  5. Login and user levels
    By seanog2001 in forum Forms
    Replies: 0
    Last Post: 10-27-2009, 05:13 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