Results 1 to 10 of 10
  1. #1
    kolsen is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    13

    DLookup Error on Query

    I am revisting Access after decades. Once knew my way around but having to relearn

    I have a query QryHoursByType that pulls info from two tables
    From table Members it gets Member Name, from table Membership Type it gets [Member Type] and [Allocated Hours]

    I wish to use a DLookup on a form to retrieve the [Allocated Hours] from the query with the criteria set by a combobox on the form

    One selects Member in Combo159 on a form called Tracker which requeries the subform and does some calculations.
    The DLookup is in the Allocated Hours text box at the bottom and is supposed to look up the number of allocated hours found in the query.
    I have

    =DLookUp("[Allocated Hours]","QryHoursByType","[Member Name]=" & [Forms]![Tracker]![Combo159])



    But this returns an error. Not sure where I am going wrong.

  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,652
    If the field is text you need delimiters:

    http://access.mvps.org/access/general/gen0018.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    kolsen is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    13
    Cant make sense of that and have left office now

  4. #4
    kolsen is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    13
    Ahh I see. The criteria is text

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Have it working now?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    kolsen is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    13
    I am in Australia. My work day is about to begin. Will let you know in half hour

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    No worries. I have a daughter in NZ, so I'm familiar with the goofed-up workday down under.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    kolsen is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    13
    OK, I have totally confused myself now

    How should I change this =DLookUp("[Allocated Hours]","QryHoursByType","[Member Name]=" & [Forms]![Tracker]![Combo159]) ?
    what should it be? This does not work
    =DLookUp("[Allocated Hours]","QryHoursByType","[Member Name]=" & [Forms]![Tracker]![Combo159] & "")

  9. #9
    kolsen is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2016
    Posts
    13
    Yay!

    I got it to work =DLookUp("[Allocated Hours]","QryHoursByType","[Member Name]= '" & [Forms]![Tracker]![Combo159] & "'")

    Those pesky apostrophes

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Glad you got it sorted.
    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. Dlookup Error
    By PicoTTS in forum Queries
    Replies: 1
    Last Post: 01-27-2016, 02:15 PM
  2. Replies: 2
    Last Post: 01-04-2016, 09:40 AM
  3. Replies: 8
    Last Post: 09-12-2015, 11:28 AM
  4. DLOOKUP #Error
    By neo651 in forum Forms
    Replies: 6
    Last Post: 12-12-2012, 12:54 PM
  5. DLookup Error
    By uncletreetrunk in forum Programming
    Replies: 5
    Last Post: 07-16-2012, 08:33 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