Solved

DSUM Lookup on Table - with Filter

Posted on 2013-01-16
10
405 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 120

Accepted Solution

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

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

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38783484
so what is now the question here?
0
 
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

839 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