Running sum - carry forward

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I want to show the sum of order line amounts (e.g. 1,4,7 = 12) on one page and show in the page footer as well as in the page header of the following page. I use running sum in a hidden textbox in the detail section and show the result in the page footer by assigning =[cPOS_mTotal_NI_Running] to an unbound textbox. Doing the same in the page header would not show the same value as on the previous page but would also include the value of the first detail line. So I used =[cPOS_mTotal_NI_Running]-[cPOS_mTotal_NI] to exclude the first detail line. This works fine as long as there is at least one detail record on the second page. If not, the amount from the last detail record on the first page will be deducted.

Another try was to calculate the value for the header in the On Print event of the detail section and to assign the calculated value to an unbound field. This works if I print immediately - i.e. without doing a preview. With a preview and a subsequent print the printed values are doubled. I used the FormatCount value to sum only if it has a value of 1.

Any other ideas?
TIA, Norbert Meiss
 
Hi Norbert,

Thank you for using MSDN Newsgroup! It's my pleasure to assist you with
your issue.

From you decription, I think you wanto have the same data, that is "order
line amounts", to be shown in one page footer and in the next page header
and you met some problem in doing so, right?

I think you can use a global variable to do this. that is, you define a
global variant to save this data and when review the pages, you can set the
value:
In Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As
Integer) you can get the sum of the order line amounts and set it to the
page foot and then save the value to this global value. When move to the
next page, in Private Sub PageHeaderSection_Print(Cancel As Integer,
PrintCount As Integer), you can read the global variable and set it to the
page head, then it will be same. In the second try, I think it is because
the caculation execute a second time when preview, you can avoid this by
using a global variable.

I hope this will solve your problem. If you still have question, please
feel free to post new message and I am ready to help.

Best regards

Baisong Wei

Microsoft Online Support
 
Hi Baisong

thanks a lot - assigning the value to a global variable
and assigning it as described did it.

Regards, Norbert
 
Back
Top