Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DSum snafu (AXP)

    Hello All,
    I have a report that contains a control with:
    =DSum("[amount]","qryExpensesJob","[expense_type]='mileage'")

    If there is actually mileage listed, the calc goes off without a hitch. However, I need it to return a 0 if there is no mileage. Consequently, I have tried this:
    =IIf(DSum("[amount]","qryExpensesJob","[expense_type]='mileage'")=Null,0,DSum("[amount]","qryExpensesJob","[expense_type]='mileage'"))

    I cannot seem to find a way to make the calc return a 0. Does anyone have any ideas?

    Thanks,
    Mark

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

    Re: DSum snafu (AXP)

    You can't use ...=Null as comparison, because Null is not really a value. Access has a special Nz function: Nz(expression, value_if_null) returns expression, unless the expression evaluates to Null; in that case it returns value_if_null. You can use

    =Nz(DSum("[amount]","qryExpensesJob","[expense_type]='mileage'"),0)

  3. #3
    4 Star Lounger
    Join Date
    Jun 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    527
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DSum snafu (AXP)

    Thanks again Hans!

    I am so rusty at VB/vba right now!

    Thanks,
    Mark

Posting Permissions

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