Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DLookup syntax error (Access 2000)

    I have a syntax error on the control in my report with the following source :
    =DLookup("[Sum2]", "[qryoutput]", _
    "[ProductID]='" & [ProductID] & "'")
    I want to get the sum Sum2 from the query qryOutput for the corresponding productid in the report.Can you help ?

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: DLookup syntax error (Access 2000)

    Because it is very difficult to read a combination of single and double-quotes, I'd use this instead:

    =DLookup("[Sum2]", "[qryoutput]", "[ProductID]=" & chr(34) & [ProductID] & chr(34) )

    I'm assuming ProductID is a text field, not numeric.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: DLookup syntax error (Access 2000)

    And if ProductID is a number field, you don't need extra quotes at all:
    <code>
    =DLookup("[Sum2]", "[qryoutput]", "[ProductID]=" & [ProductID])
    </code>
    Note that you can't use the line continuation character _ in the control source of a control. The line continuation character is for use in VBA code only.

  4. #4
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DLookup syntax error (Access 2000)

    Indeed, i have it done, and it works great !!!

Posting Permissions

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