Solved

DSUM Lookup on Table - with Filter

Posted on 2013-01-16
10
404 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 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How can I Flash a mandatory field in Access Form? 13 48
Access Update Query 1 20
DCount Type Mismatch 2 22
Field naming convntions - MS Access 7 29
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

777 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