Results 1 to 2 of 2
  1. #1
    runtest is offline Novice
    Windows Vista Access 2003
    Join Date
    Feb 2010
    Posts
    3

    Logging In

    I searched the forums but did not find a solution to my problem. Any help would be very appreciated. Further more, answering this question would answer about 35 other questions I have.



    Code:
    Private Sub cmdLogin_Click()
    
    On Error GoTo ErrorPoint
    
       If Len(Nz(Me!txtUserName, "")) = 0 Then
           ' User Name box is empty
           MsgBox "Please select your user name before continuing.", _
           vbInformation, "Enter User Name"
           Me.txtUserName.SetFocus
           GoTo ExitPoint
       End If
    
       If Len(Nz(Me!txtPassword, "")) = 0 Then
           ' Password box is empty
           MsgBox "Please enter your password before continuing.", _
           vbInformation, "Missing Password"
           Me.txtPassword.SetFocus
           GoTo ExitPoint
       End If
    
    ExitPoint:
       Exit Sub
    
    ErrorPoint:
       MsgBox "The following error has occurred:" _
       & vbNewLine & "Error Number: " & Err.Number _
       & vbNewLine & "Error Description: " & Err.Description _
       , vbExclamation, "Unexpected Error"
       Resume ExitPoint
    
    End Sub
    This is the code I have for my login button. I have linked the tables to my access project. The table is called.

    tblUsers

    The four keys in the table is.

    Employee ID | AccessLevel | Username | Password


    The form I am trying to open when a correct authentication is processed is.

    Main

    Any help would really be appreciated. By seeing a working example of this it would answer several key questions I have.
    Note: The txtUserName box is actually a combo-box with a drop down of the user names.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,095
    The simplest method would be to use a DCount() function to test the user/password combination against your user table. If the count is greater than zero, you have a valid login. More info on syntax here:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Access Data Logging
    By pix in forum Access
    Replies: 0
    Last Post: 05-11-2009, 01:10 PM

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