G
G
I had posted previously and received wonderful assistance.
I just have one more question.
I need to programmatically add a % of the report total to
the last available column in my report.
I'm not quite sure where to place the percentage coding.
The last 2 available columns are for the row totals and
the % of report total.
The detail print section goes through each row, adds the
value to the report total, then puts the row total to the
right. Then it goes to the next row.
I don't get a correct report total until it completes the
cycle. So I cannot put it with the detail print coding.
Should I assign the textbox source in the report footer
onprint event?
I'll put the sample and coding below. Thank you in advance
for your assistance.
G
Sample Layout
Total % of Report
9,900 0.00%
500 0.00%
Group total goes here
10,400 0.00%
Report total goes here
10,400 100.00%
The coding for detail section onprint
Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
Dim intX As Integer
Dim lngRowTotal As Double, dblPct As Double
' If PrintCount is 1, initialize lngRowTotal variable.
' Add to column totals.
If Me.PrintCount = 1 Then
lngRowTotal = 0
For intX = 1 To intColumnCount - 4
' Starting at column 2 (first text box with
crosstab value),
' compute total for current row in detail
section.
lngRowTotal = lngRowTotal + Me("txtDet" +
Format$(intX))
' Add crosstab value to total for current column.
lngRgColumnTotal(intX) = lngRgColumnTotal(intX)
+ Me("txtDet" + Format$(intX))
Next intX
' Place row total in text box in detail section.
Me("txtDet" + Format$(intColumnCount - 3)) =
lngRowTotal
'Place the column total in the footer for each
subgrouping
For intX = 1 To intColumnCount
'need to fix the 2nd half of the line below
'Me("txtAssetClassFooter" +
Format$(intColumnCount - 3)) = Me("txtDet" +
Format$(intColumnCount - 3))
Next intX
'Add row total for current row to grand total.
lngReportTotal = lngReportTotal + lngRowTotal
'this procedure is adding the first column's
data to the percentage column.
'Add the percentages to the far right column
End If
End Sub
----------------------
REPORT FOOTER ONPRINT CODING
Private Sub ReportFooter_Print(Cancel As Integer,
PrintCount As Integer)
Dim intX As Integer
' Place column totals in text boxes in report footer.
' Start at column 2 (first text box with crosstab
value).
For intX = 1 To intColumnCount - 3
Me("txtGT" + Format$(intX)) = lngRgColumnTotal
(intX)
Next intX
' Place grand total in text box in report footer.
Me("txtGT" + Format$(intColumnCount - 3)) =
lngReportTotal
' Hide unused text boxes in report footer.
For intX = intColumnCount + 2 To conTotalColumns - 3
Me("txtGT" + Format$(intX)).Visible = False
Next intX
End Sub
I just have one more question.
I need to programmatically add a % of the report total to
the last available column in my report.
I'm not quite sure where to place the percentage coding.
The last 2 available columns are for the row totals and
the % of report total.
The detail print section goes through each row, adds the
value to the report total, then puts the row total to the
right. Then it goes to the next row.
I don't get a correct report total until it completes the
cycle. So I cannot put it with the detail print coding.
Should I assign the textbox source in the report footer
onprint event?
I'll put the sample and coding below. Thank you in advance
for your assistance.
G
Sample Layout
Total % of Report
9,900 0.00%
500 0.00%
Group total goes here
10,400 0.00%
Report total goes here
10,400 100.00%
The coding for detail section onprint
Private Sub Detail_Print(Cancel As Integer, PrintCount As
Integer)
Dim intX As Integer
Dim lngRowTotal As Double, dblPct As Double
' If PrintCount is 1, initialize lngRowTotal variable.
' Add to column totals.
If Me.PrintCount = 1 Then
lngRowTotal = 0
For intX = 1 To intColumnCount - 4
' Starting at column 2 (first text box with
crosstab value),
' compute total for current row in detail
section.
lngRowTotal = lngRowTotal + Me("txtDet" +
Format$(intX))
' Add crosstab value to total for current column.
lngRgColumnTotal(intX) = lngRgColumnTotal(intX)
+ Me("txtDet" + Format$(intX))
Next intX
' Place row total in text box in detail section.
Me("txtDet" + Format$(intColumnCount - 3)) =
lngRowTotal
'Place the column total in the footer for each
subgrouping
For intX = 1 To intColumnCount
'need to fix the 2nd half of the line below
'Me("txtAssetClassFooter" +
Format$(intColumnCount - 3)) = Me("txtDet" +
Format$(intColumnCount - 3))
Next intX
'Add row total for current row to grand total.
lngReportTotal = lngReportTotal + lngRowTotal
'this procedure is adding the first column's
data to the percentage column.
'Add the percentages to the far right column
End If
End Sub
----------------------
REPORT FOOTER ONPRINT CODING
Private Sub ReportFooter_Print(Cancel As Integer,
PrintCount As Integer)
Dim intX As Integer
' Place column totals in text boxes in report footer.
' Start at column 2 (first text box with crosstab
value).
For intX = 1 To intColumnCount - 3
Me("txtGT" + Format$(intX)) = lngRgColumnTotal
(intX)
Next intX
' Place grand total in text box in report footer.
Me("txtGT" + Format$(intColumnCount - 3)) =
lngReportTotal
' Hide unused text boxes in report footer.
For intX = intColumnCount + 2 To conTotalColumns - 3
Me("txtGT" + Format$(intX)).Visible = False
Next intX
End Sub