Using MoveLayout to print subtotal on last detail line of group

T

Tony M

Hi all. I am trying to get a report to print subtotals on the same
line as the last detail line of a section, for example:

Section Boxes Total
A 10
A 22 32
B 35
B 38
B 10 83
C 44 44
D 10
D 10 20

My report has a detail section and a group footer section, with the
group footer section having the total of boxes.

From my understanding of this page:

http://msdn.microsoft.com/en-us/library/aa195329(office.10).aspx

setting MoveLayout to False in the Format event of a section will
cause the section to "Print the current record on top of the last
record as an overlay." Yet, my totals are overlaid one line too late.
In my example, the total of 32 for A will print on the first line of
section B.

What am I doing wrong?
 
D

Duane Hookom

You should share your code.

I think you need to run the MoveLayout in the On Format of the final detail
record.
Add a text box to the detail section:
Name: txtCountGroupRS
Control Source: =1
Running Sum: Over Group
Visible: No

Add a text box to the Group Footer section:
Name: txtCountGroup
Control Source: =Count(*)
Running Sum: No
Visible: No

Add code to the On Format event of the detail section:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.MoveLayout = (Me.txtCountGroup <> Me.txtCountGroupRS)
End Sub
 
T

Tony M

You should share your code.

I think you need to run the MoveLayout in the On Format of the final detail
record.
Add a text box to the detail section:
Name: txtCountGroupRS
Control Source: =1
Running Sum: Over Group
Visible: No

Add a text box to the Group Footer section:
Name: txtCountGroup
Control Source: =Count(*)
Running Sum: No
Visible: No

Add code to the On Format event of the detail section:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.MoveLayout = (Me.txtCountGroup <> Me.txtCountGroupRS)
End Sub

Thank you, your post did exactly what I was looking for. I'll post
code next time something I cry for help.

Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top