Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006

    Unanswered: Login form code problems

    Hello all, i am trying to implement a login form for users, but i am having problems with the code for cmdLogin_Click(). It keeps saying there is a run time error 2501 on this line of code. I'm fairly new to VBA, can anyone help? Here is the code for the on click event, the line in red which is the filter is the one i am having problems with.

    Private Sub cmdLogin_Click()

    'Used when the user moves out of txtPassword

    'Filter the record for the form the LoginID (unique primary key)
    'Filter for matching login id

    DoCmd.ApplyFilter , "[LoginID] = forms![frmLogin]!txtLogin"

    'If a match is found then the the LoginID and Password from the table will be found in bound fields on the form
    'They can be used to check with what the user has typed in

    If IsNull(LoginID) Then 'No match for LoginID found
    myDisplayWarningMessage "Invalid Login ID"
    ElseIf Password <> txtPassword Or IsNull(txtPassword) Then 'Invalid or missing password
    myDisplayWarningMessage "Invalid Password"

    Else 'Valid log in, password

    myOKBox "Welcome " & FirstName & "" & LastName & ""
    'Welcome message

    DoCmd.OpenForm "frmMainMenu"
    'Open the main menu

    'Close this form

    End If

    End Sub
    Last edited by c02dm; 05-01-06 at 08:08.

  2. #2
    Join Date
    Dec 2004
    Madison, WI


    You can try the code below for getting users login.
    Attached Files Attached Files
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts