Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Posts
    2

    Red face Unanswered: Login screen code problem

    ok, it is 1143pm in korea where i am currently stationed, i have been working on a unit database since friday, lots of macros and VBA Code running. Almost finished with the tricks and treats before splitting to the share drive and packaging the front end. one problem and maybe just me being at it for days and going (trying to meet a deadline) The below is code i have looked at a few times and cant seem to peg what i am missing here. I keep getting Runtime Error 2471: The Expression you entered as a query parameter produced this error "robert.towler" when attempting to test the login form. it gives the error and debug points this statement. Full Code is below, it compiles fine, just when i attempt login using the form does it produce the error. If anyone can help with this, maybe take the code and recreate the error, my table is named "AccountTable" this is the reference in the code that stores the username and actual password to be checked for. Any questions or comments please post back. Thanks Much in Advance.

    If Forms!LoginScreen!Password.Value = DLookup("Password", "AccountTable", "[UserName]=" & Forms!LoginScreen!Combo11.Value) Then

    .................................................. ................................................

    Option Compare Database


    Private Sub Combo11_AfterUpdate()
    'After selecting user name set focus to password field
    Forms!LoginScreen!Password.SetFocus
    End Sub

    Private Sub Command5_Click()
    'Check to see if data is entered into the UserName combo box

    If IsNull(Forms!LoginScreen!Combo11) Or Forms!LoginScreen!Combo11 = "" Then
    MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
    Forms!LoginScreen!Combo11.SetFocus
    Exit Sub
    End If

    'Check to see if data is entered into the password box

    If IsNull(Forms!LoginScreen!Password) Or Forms!LoginScreen!Password = "" Then
    MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
    Forms!LoginScreen!Password.SetFocus
    Exit Sub
    End If

    'Check value of password in AccountTable to see if this
    'matches value chosen in combo box

    If Forms!LoginScreen!Password.Value = DLookup ("Password", "AccountTable", "[UserName]=" & Forms!LoginScreen!Combo11.Value) Then

    lngMyEmpID = Forms!LoginScreen!Combo11.Value

    'Close logon form and open splash screen

    DoCmd.Close acForm, "frmLoginScreen", acSaveNo
    DoCmd.OpenForm "frmSwitchboard"

    Else
    MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
    "Invalid Entry!"
    Forms!LoginScreen!Password.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 admin.", _
    vbCritical, "Restricted Access!"
    Application.Quit
    End If

    End Sub


    .................................................. ..................................................




    Any Help Please, Thanks

    SGT Towler, Robert
    US Army

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Your syntax is correct, assuming that [UserName] is Numeric! Given the name, it seems likely, however, that it is Text! In which case it should be
    Code:
    DLookup ("Password", "AccountTable", "[UserName]= '" & Forms!LoginScreen!Combo11.Value & "'")
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Apr 2010
    Posts
    2

    Thumbs up

    Thank you, that was it...now i have a fully integrated login screen that the admin can input usernames and passwords for the front end, while users cant add, delete, or modify the username table to bypass security once they are logged in.

    Again Thank you.

    dont know how i missed that

    maybe i need to drink more lmao

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Glad we could help!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

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