Solved

DSUM Lookup on Table - with Filter

Posted on 2013-01-16
10
402 Views
Last Modified: 2013-01-16
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?
0
Comment
Question by:CFMI
  • 5
  • 4
10 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 375 total points
ID: 38783384
syntax is

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

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 125 total points
ID: 38783391
this should do:


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

Author Comment

by:CFMI
ID: 38783445
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
0
 
LVL 1

Author Comment

by:CFMI
ID: 38783457
Or how about if  "Is NOT Null([Srce_Type] ??"  . . I know that's a third scenario but thanks.
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38783484
so what is now the question here?
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:CFMI
ID: 38783506
3) if the event should occur where [Srce_Type] is NOT null, then what is syntax?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 38783540
<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
0
 
LVL 1

Author Comment

by:CFMI
ID: 38783579
"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.
0
 
LVL 119

Assisted Solution

by:Rey Obrero
Rey Obrero earned 375 total points
ID: 38783585
<I'm looking for totals of ALL records where [Srce_Type] is null or empty or blank. >

then use this

If DSum("[Amt]", "[In]", "[Srce_Type] is Null") = 0 then

or


If DSum("[Amt]", "[In]", "IsNull([Srce_Type])") = 0 then
0
 
LVL 1

Author Closing Comment

by:CFMI
ID: 38783612
Thanks so much for your patience.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now