UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Sub Forms Addition Not Working Properly On Main Form, Access 2010    
 
   
Matt_S
post Jan 13 2018, 12:25 AM
Post#1



Posts: 53
Joined: 12-February 17



Good evening all (evening here on the east coast of the US),
I have two sub forms on a main form. The two sub forms have running sum text boxes in their footers.
I have text boxes in the main form that (should) sum the totals from the sub forms. The expression I am using in the control source of the main form text box is :
CODE
=[Subform1].[Form]![runningSum]+[Subform2].[Form]![runningSum]

The problem I am running into is the main form expression doesn't seem to do anything unless there is something in the subform2 running total. Which may not always be the case in use.
I can throw a zero in and it works but it seems I should not have to do that. Is my expression written wrong or am I missing something?
Go to the top of the page
 
HairyBob
post Jan 13 2018, 06:10 AM
Post#2



Posts: 882
Joined: 26-March 08
From: London


Hi Matt,

Something plus Null (unknown) results in Null. Try changing you expression to:

CODE
=[Subform1].[Form]![runningSum] + Nz([Subform2].[Form]![runningSum], 0)


HTH...

Hairy.
This post has been edited by HairyBob: Jan 13 2018, 06:11 AM

--------------------
If it was easy, It wouldn't be fun!
Go to the top of the page
 
GroverParkGeorge
post Jan 13 2018, 08:13 AM
Post#3


UA Admin
Posts: 31,569
Joined: 20-June 02
From: Newcastle, WA


"Null" is one of those fascinating topics that make learning to use VBA and SQL in Access so interesting, as well as challenging.

If you have a few minutes--or hours--to invest, it's well worth the time it will take to dive into the subject.

Here's a good place to start in the realm of SQL. Similar concepts apply to your expression in the control on a form.

--------------------
Go to the top of the page
 
Matt_S
post Jan 13 2018, 05:30 PM
Post#4



Posts: 53
Joined: 12-February 17



Thank you both. I hadn't thought about null values with the expression I used.
More to the point I didn't really think of it as an "SQL" statement because it was so simple. Thinking no entry was zero. I guess it is always good practice to wrap potential nulls in Nz.
Go to the top of the page
 
GroverParkGeorge
post Jan 14 2018, 07:10 AM
Post#5


UA Admin
Posts: 31,569
Joined: 20-June 02
From: Newcastle, WA


I worried about posting that link, because an expression in a control really isn't SQL, as I noted, " Similar concepts apply to your expression ... "

But, yes, it is really a very interesting part of working with data in Access.

--------------------
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    17th January 2018 - 08:22 AM