View Full Version : Sum Totals in Subforms


Uli
08-16-2000, 07:40 AM
Hi,

I'm new here on the recommendation of a good friend and one post in this forum already related to a problem I was trying to solve for a few days now. It's great.

Right now, I'm struggling with the following question. I have a main form with 3 subforms all linked on a field called PositionCode.

I have added a control to the bottom of my main form to sum the subtotals of each subform and add it to another total in my main form. This works like a charm as long as there are child records in each subform. If I don't have a matching child record in each of the subforms I get a blank in the control (the business process doesn't require me to have a child record for every main record). It probably has to do with it trying to add "null values" to numbers. I'm just not sure how to deal with getting by that. The way I'm doing it right now is to automatically create a record in each child table as soon as I'm adding a new record to the main table. That is probably redundant though.

Any suggestions?

Thanks
Uli

Jack Cowley
08-16-2000, 10:50 AM
Search help for Nz function. I am not sure what your code looks like but here is a crude example:

=Sum(Nz([Subform1Total]) + Nz([Subform2Total]))

I think you get the idea. If one of the subform totals is null it will be replaced with a 0 and your calculation will not crash.

HTH,
Jack

Uli
08-16-2000, 11:13 AM
Thank you Jack. That worked. Now I can trash the code that added a record with a zero value every time I created a new main record. I was going the real complicated route.

Muchly appreciated.

Uli