Results 1 to 9 of 9
  1. #1
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55

    Dlookup not working


    I haven't used Dlookup before and am using the syntax bellow which I found on line but just get Name?? in my unbound text box. Is there something wrong with my syntax? Ive tried everything I can think of. My fields are both text fields. Help is much appreciated.

    =DLookUp("Our Sales Price","tbl_Price","[TypeofTicket]= " & [Type of Ticket] & " And [AttractionID]= '" & [SKU] & "'")

  2. #2
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,399
    because you have spaces, Our Sales Price must be in square brackets - [Our Sales Price]

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If both fields are text the first value needs ' around it like the second. You may also need to bracket the fields with inadvisable spaces.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    I tried the brackets but still get the same error message. Im really unsure where to place the extra ' as I just don't understand what they are needed for, thanks so much for trying to help me, it is really appreciated and its driving me nuts

    =DLookUp("[Our Sales Price]","tbl_Price","[TypeofTicket]= " & [Type of Ticket] & " And [AttractionID]= '" & [SKU] & "'")

  5. #5
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    Could it be something to do with Our Sales Price being a currency field? the fields being looked up are both text as I said but maybe I have to treat a currency field differently....im not sure

  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,518
    Try

    DLookUp("[Our Sales Price]","tbl_Price","[TypeofTicket]=
    '" & [Type of Ticket] & "' And [AttractionID]= '" & [SKU] & "'")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,825
    Parameters for text fields need apostrophe delimiters, date fields need # delimiters, number type do not need delimiters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    shaunacol is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    55
    It works!! It works!!! pbadly you are a genius thank you x

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    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. Three criteria in Dlookup not working?
    By dcdimon in forum Programming
    Replies: 5
    Last Post: 07-03-2014, 07:04 AM
  2. Yet Another Dlookup isn't working thread
    By g4tv4life in forum Programming
    Replies: 8
    Last Post: 02-07-2014, 01:15 PM
  3. PLEASE HELP! Dlookup event not working....
    By emailloni in forum Forms
    Replies: 11
    Last Post: 01-10-2013, 12:43 PM
  4. Autofill using DLookup not working
    By BBonexx in forum Access
    Replies: 2
    Last Post: 01-08-2013, 09:18 PM
  5. DLookup isn't working
    By cec in forum Access
    Replies: 7
    Last Post: 12-28-2012, 12:21 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