Link to home
Start Free TrialLog in
Avatar of CFMI
CFMIFlag for United States of America

asked on

DSUM Lookup on Table - with Filter

I have a form into which I'm using an "On Open" event.  If the total for [In] table of the [Amt] field = 0, where grouped [Srce_Type] = "Lockbox", then perform an operation.

I know I could write a GROUP BY query to return the desired output but was hoping to filter and sum total in a simpler way.  
Example:     If DSum("[Amt]", "[In]", [Srce_Type] = "Lockbox") = "0" Then

Is there a simple VBA line which would perform this operation?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CFMI

ASKER

Okay now let's build on that.  Two scenarios:
1) If there are two possible filters - either Lockbox / or Cashbox, do I enter

If DSum("[Amt]", "[In]", "[Srce_Type] = 'Lockbox'") = 0 or If DSum("[Amt]", "[In]", "[Srce_Type] = 'Cashbox'") = 0 Then

2) If IsNull [Srce_Type], do I enter

If DSum("[Amt]", "[In]", "IsNull([Srce_Type])") = 0 Then
Avatar of CFMI

ASKER

Or how about if  "Is NOT Null([Srce_Type] ??"  . . I know that's a third scenario but thanks.
so what is now the question here?
Avatar of CFMI

ASKER

3) if the event should occur where [Srce_Type] is NOT null, then what is syntax?
<if the event should occur where [Srce_Type] is NOT null, then what is syntax? >

i don't understand, what you are trying to do, first you want to get the sum, using

If DSum("[Amt]", "[In]", "[Srce_Type] = 'Lockbox'") = 0 then

if   [Srce_Type] is null or emplty or blank, then it will not be included in the SUM of the AMT
Avatar of CFMI

ASKER

"if [Srce_Type] is null or empty or blank, then it will not be included in the SUM of the AMT"

That is correct but in the prior statements I was looking for totals for only certain records.  In this case, I'm looking for totals of ALL records where [Srce_Type] is null or empty or blank.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CFMI

ASKER

Thanks so much for your patience.