Results 1 to 2 of 2
  1. #1
    Lounger
    Join Date
    Jan 2007
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DLookup (Access 2003)

    I am trying to use the DLookup function to display on my form. I created a text box in the footer section of my report and added the following to the control source of the text box:

    =IIf(DLookUp("Expression","table1","ID=1395"),(DLo okUp("Expression","table1","ID=1395") & " " & ((DLookUp(Sum([Price]),"query1",[SubtotalOn]=1390))+(DLookUp(Sum([Price]),"query1",[SubtotalOn]=1350)))),"nothing")

    I get blank because I think it's not adding the two DLookUp's together.
    Is there a way to use the DLookup function in an IFF statement to add up two values retrieved from another DLookup?

    Thanks.

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

    Re: DLookup (Access 2003)

    1) All arguments to DLookup should be strings, not expressions.
    2) Instead of DLookup("Sum(...)", ...) you can use DSum(..., ...)
    3) You can combine criteria using And, Or etc.
    So try

    DSum("Price","query1","SubtotalOn=1390 Or SubtotalOn=1350")

Posting Permissions

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