Results 1 to 6 of 6
  1. #1
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72

    DLookup Error

    Hi all,



    I'm not sure what I am doing wrong, but when I run the code below I get a Error 2471, The expression you entered as a query parameter produced this error 'u09515'

    Unfortunately, I don't know if that u09515 is from the table I'm pulling from or the unbound textbox txtUser. :/

    The ultimate goal is to enter a value into txtPW and txtUser and to use DLookup to check if that is a valid user/password combination and allow them access to the database.

    Thanks in advanced!

    Code:
    If Me.txtPW.Value = DLookup("Password", "tblLogin", "[UserName] = " & Me.txtUser.Value) Then
    DoCmd.Close acForm, "frmLogin"
    Else
        MsgBox "Invalid password/user name combination. Please try again.", vbOKOnly, "Login Error"
        Me.txtPW.SetFocus
    End If

  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,640
    If the field is text the syntax is slightly different:

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

  3. #3
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72
    Thanks pbaldy,

    So I know should be using: DLookup("FieldName" , "TableName" , "Criteria= 'string'")

    But since my string is coming from an unbound textbox, How should I call the string? Because Calling 'Me.txtUser.Value' is invalid syntax

  4. #4
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72
    Whoop hold on... I didn't read that link very carefully

  5. #5
    uncletreetrunk is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2012
    Posts
    72
    Thank you pbaldy! haha I didn't read the link very carefully the first time. That was exactly what I was looking for!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help?
    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. Error in Dlookup?
    By cindytan in forum Forms
    Replies: 1
    Last Post: 02-07-2012, 02:40 AM
  2. Newbie. DLookup gives type mismatch error.
    By graffiti in forum Programming
    Replies: 4
    Last Post: 12-13-2011, 05:22 AM
  3. Error using ELookup but not DLookup
    By Rawb in forum Programming
    Replies: 12
    Last Post: 10-18-2010, 07:09 AM
  4. DLookup error
    By jgelpi16 in forum Programming
    Replies: 3
    Last Post: 08-25-2010, 07:26 AM
  5. Dlookup in form returns #error
    By RickM in forum Access
    Replies: 1
    Last Post: 03-29-2010, 07:59 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