Null Calculation (1 Viewer)

Carol

Registered User.
Local time
Today, 20:54
Joined
Jan 15, 2000
Messages
280
I have a subform which has a listing for additional costs if required. The user inputs the detail and the amount. This is a continuous form, based upon a ConcernID. I have a total in the form footer which gives an overall additional cost total. This total is then transferred to the main form. The problem is these additional fields are not always used. If there are not additional costs, there is not a total field that can be used for the main form and hence the overall cost total (calculated field) of the main form is not showing a total . I would like the total on the subform to state 0 if no records. My control source in my subform is as follows:
=Sum(NZ([Amount],0))
My conrol source in my main form for the total is as follows:
=IIf(IsNull([ConcernID]),0,DSum("[Amount]","ConcernOtherCosts","[ConcernID]=" & [ConcernID]))
My control source in my main form for the overall ConcernID total is as follows:
=NZ([Labour]+NZ([Travel])+NZ([Other])+NZ([Trucking])+NZ([Costs])+NZ([Parts]))

What am I missing.

Thanks.
 
A

Afterglow

Guest
When using the Null Zero command as you have. You must us a Capital “N” and a lowercase “z”. So it would look like Nz. =Nz([Labour]+Nz([Travel])+Nz([Other])+Nz([Trucking])+Nz([Costs])+Nz([Parts]))
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 15:54
Joined
Feb 19, 2002
Messages
43,297
The Nz() function works slightly differently in SQL from how it works in code. The CORRECT and COMPLETE format for the command is Nz(yourfield,valueToReturnWhenYourFieldIsNull), therefore, change your code to:
=NZ([Labour,0]+ ...etc.

In SQL where you probably got your example, the default value to return is 0. There is no default when the function is used in code.
 

Users who are viewing this thread

Top Bottom