ACC2002: Reports Saved as Data Access Pages Are Missing Grand Totals (282381)
The information in this article applies to:
This article was previously published under Q282381 Novice: Requires knowledge of the user interface on single-user computers.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
SYMPTOMS
When you save a report that contains a grand total as a data access page, the Grand Total box is blank.
CAUSE
This behavior occurs because you cannot bind controls in the Caption or Record Navigation section of a data access pages.
RESOLUTION
To work around this behavior, use one of the following methods.
Method 1
If the report is not based on any group, it will not create group headers/footers when you save it as a data access page. Therefore, to create a grand total, use the following method:
- In the sample database Northwind.mdb, click Reports in the Database window, and then click New.
- In the New Report dialog box, click Report Wizard, click the Products table in the Choose the table or query where the object's data comes from box, and then click OK.
- In the Report Wizard, select the following fields from the Available Fields list, and then move them to the Selected Fields list:
ProductName
CategoryID
UnitPrice
- Click Next, remove any group levels, and then click Next two times.
- For Layout, select Tabular, and then click Finish.
- On the View menu, click Design View.
- On the File menu, click Save As.
- In the Save As dialog box, click Data Access Page in the As list, and then click OK.
- In Page view of the newly created data access page, click Design View on the View menu.
- In the Header: Products section of the data access page, click in the UnitPrice text box.
- On the toolbar, click the arrow on the AutoSum toolbar button. Note that there are options for Sum, Average, Min, Max, Count, StDev, and Any.
- Click Sum in the list. This creates a Footer: Products-UnitPrice section with a Bound Span control named SumOfUnitPrice.
- On the View menu, click Page View to view the sum of UnitPrice column in the data access page.
Method 2
If the report is based on groups and each group has one or more totals followed by a grand total, the grand total will appear blank when you save the report as a data access page. The following steps show you how to workaround this behavior:
- In the sample database Northwind.mdb, click Reports in the Database window, and then click New.
- In the New Report dialog box, click Report Wizard, click the Products table in the Choose the table or query where the object's data comes from box, and then click OK.
- In the Report Wizard, select the following fields from the Available Fields list, and then move them to the Selected Fields list:
ProductName
CategoryID
UnitPrice
- Click Next two times, and then click Summary Options.
- In the Summary Options dialog box, click to select the Sum check box, click OK, and then click Finish.
- On the View menu, click Design View.
- On the File menu, click Save As.
- In the Save As dialog box, click Data Access Page in the As list, and then click OK.
- In Page view of the newly created data access page, scroll to the bottom of the page and note that the Grand Total box is blank.
- On the View menu, click Design View.
- On the Tools menu, point to Macro, and then click Microsoft Script Editor.
- In the Object list, click MSODSC.
- In the Events list, click DataPageComplete. The following script is inserted:
<SCRIPT language=vbscript event=DataPageComplete for=MSODSC>
<!--
-->
</SCRIPT>
IMPORTANT: When you create VBScript blocks for MSODSC events, you must add a parameter to the event name, as follows:
<SCRIPT language=vbscript event=DataPageComplete(obj) for=MSODSC>
<!--
-->
</SCRIPT>
The obj parameter added above is used to return specific information about the event to the script. You must add this parameter, regardless of whether it will be used or not, because the script will not work without it. - Enter the following script within these script tags:
Const FooterLevel = 3
Dim curGrandTot
Dim sectionFooter
'[ProductSales Grand Total Sum] is the name of a text box that
'should already reside in the Navigation: GroupLevel0
'section of this data access page.
If [ProductSales Grand Total Sum].value = "" Then
Set sectionFooter = obj.DataPage.FirstSection
While Not (sectionFooter Is Nothing)
'Test to make sure that focus is in
'the Footer: GroupLevel0 section.
If sectionFooter.type = FooterLevel Then
'The following line accumulates each of the totals per group
'to create a grand total.
curGrandTot = curGrandTot + CCur(sectionFooter.HTMLContainer.children("Sum Of ProductSales").value)
End If
Set sectionFooter = sectionFooter.NextSection
Wend
'Fill the control with the frand total.
[ProductSales Grand Total Sum].value = curGrandTot
End If
REFERENCESFor more information about creating access data pages, click Microsoft Access Help on the Help menu, type about the types of web pages access creates in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about creating grand totals, click Microsoft Access Help on the Help menu, type calculate a total or other aggregate values in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Minor | Last Reviewed: | 9/27/2006 |
---|
Keywords: | kbnofix kbprb KB282381 |
---|
|