435,241 Members | 775 Online
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

# sum on subform and main form

 P: n/a Sorry that this is rather basic. But I have tried the various suggestions given in this group and cannot get them to work. I have a main form, for simplicity called "Main". On it are two subforms. For simplicity subform1 and subform2. subform1 lists fees for items. The sum of all fees for all items is in a text box on the footer of subform1. PurSum =Sum([Fee]). subform2 contains exactly the same field, fees for items of a different type. The sum is again given in the footer in a text box, SaleSum = Sum([Fee]). So far so good and it all works well. Try as I might I cannot get a text box in the footer of the main form to display the total for the total boxes on each subform, ie Total = PurSum + SaleSum. Have tried Total = [subform1].[mainform]![PurSum] + [subform2]. [mainform]![SaleSum] to no avail. Any suggestions or observations would be gratefully received. Sorry to all the experts to whom this is an elementary point fully covered elsewhere in the group. Have looked for three hours and tried different approaches without success. Jul 2 '07 #1
2 Replies

 P: n/a The "mainform" bit is wrong. You need the word "Form" there. It would be good to include Nz() to handle the case where one of the subforms has a total of Null: =Nz([subform1].[Form]![PurSum],0) + Nz([subform2].[Form]![SaleSum],0) That should work unless a subform is completely blank (no records, not even the new record row.) For an explanation of what the ".Form" is, see: Referring to Controls on a Subform at: http://allenbrowne.com/casu-04.html -- Allen Browne - Microsoft MVP. Perth, Western Australia Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org.

 P: n/a Shortly after posting this problem I found that =[subform1].Form!pursum+[subform2].Form!salesum was working. It may help other readers if I mention my problem was that during development the main form and subforms had had different names and those names had remained as the "Source Object" when I looked at the properties for them. As soon as I used the correct names I began to move forward. Your solution is excellent. Many thanks for taking time to consider the issue Jul 3 '07 #3

### This discussion thread is closed

Replies have been disabled for this discussion.