Solved

Access - SubForm based on Query - Sum if query Is Null

Posted on 2013-01-31
2
514 Views
Last Modified: 2013-02-02
Hello all
I have a Form.  On that Form I Have a textbox where I display an amount from a formula that pulls totals from 3 Subforms.  

The 3 Subforms Each have a textbox in the header where I Sum([TrAmt]) .  Each Subform is based upon a different query.

Everything works right until in that Main Form textbox on the Main Form UNLESS one of the SubForm's queries is Null.  


I have tried nz(Sum([TrAmt],0) but if the Subform's query is null that textbox field just displays as blank.   Then the Main Form's textbox goes into an #Error state.

Any Suggestion?
0
Comment
Question by:wlwebb
2 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 38843028
NZ() won't have any effect if the value does not exist.

Try this approach...
Put a hidden textbox on the subform, and set its controlsource to:
 =Count(somefieldwhichwouldneverbenull)
Say this is called Kount

Then in the main form you can do...

=IIf([subctrl1].[Form]![Kount]>0,[subctrl1].[Form]![thesumcontrol],0)
0
 

Author Closing Comment

by:wlwebb
ID: 38847960
Thanks Peter that worked with some modification
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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 …

863 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

20 Experts available now in Live!

Get 1:1 Help Now