Microsoft KB Archive/287445

= ACC2002: Cannot Bind a Grouped Report That Was Saved as a Data Access Page to XML =

Article ID: 287445

Article Last Modified on 9/27/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q287445



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
When you bind a data access page that was saved from a grouped report to XML, only the lowest level group on the page is bound. Other groups on the page do not display data.



CAUSE
There are brackets ([]) in the names of page field objects on the page.



RESOLUTION
Remove the brackets from the page field objects on the page as follows:

CAUTION: Following the steps in this example will modify your data access page. You may want to back up the page and perform these steps on a copy of the page.
 * 1) Start Access 2002, and then open the database that contains your page.
 * 2) Click your data access page in the Database window, and then open it in Design view.
 * 3) On the View menu, click Data Outline to view the data model for the page.
 * 4) Right-click a page field that has brackets listed in the data outline, and then click Properties. The title on the Properties dialog box should read PageField: [FieldName]
 * 5) Remove the brackets from the Name property of the page field.
 * 6) Save the page, and then view it in Page view. All the fields on the page should be bound to XML.

If your page has many page fields that contain brackets around the name, you can use Visual Basic for Applications code to programmatically remove the brackets from the names. To do so, follow these steps.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.  Start Access 2002, and then open the database that contains your page. In the Database window, click Modules under Objects, and then click New.  Type or paste the following code into the new module: Sub RemoveBrackets(strPageName As String) On Error GoTo RemoveBracketErrors Dim dap As DataAccessPage Dim gdf As Object  ' GroupingDef object Dim pgf As Object  ' PageField object Dim strNewName As String ' if the page is not open, open it in Design view If Not CurrentProject.AllDataAccessPages(strPageName).IsLoaded Then DoCmd.OpenDataAccessPage strPageName, acDataAccessPageDesign End If   ' set the object variable Set dap = DataAccessPages(strPageName) ' iterate through grouping definitions on the page For Each gdf In dap.MSODSC.AllGroupingDefs ' loop through AllPageFields collection For Each pgf In gdf.PageFields ' find PageFields that contain brackets in the name If InStr(1, pgf.Name, &quot;[&quot;) > 0 Then ' remove the brackets and rename the PageField strNewName = Mid(pgf.Name, 2, InStr(2, pgf.Name, &quot;]&quot;) - 2) pgf.Name = strNewName End If       Next Next ' close and save the page DoCmd.Close acDataAccessPage, strPageName, acSaveYes RemoveBracketExit: ' cleanup Set pgf = Nothing Set gdf = Nothing Set dap = Nothing MsgBox &quot;Page fields with brackets have been renamed&quot; Exit Sub RemoveBracketErrors: Const CON_ERR_CANNOTFINDPAGE = 7874 Const CON_ERR_CANNOTFINDOBJ = 2467 If (Err = CON_ERR_CANNOTFINDPAGE Or Err = CON_ERR_CANNOTFINDOBJ) Then MsgBox &quot;Cannot find the specified page: &quot; & vbCrLf & vbCrLf & strPageName, vbInformation Resume RemoveBracketExit Else MsgBox &quot;An error has occurred: &quot; & vbCrLf & _ Err.Description & vbCrLf & _ &quot;number: &quot; & Err.Number End If End Sub  Save the module as basRemoveBrackets . To test the procedure, type the following line in the Immediate window, and then press ENTER

RemoveBrackets &quot; &quot;

where  is the name of your page as it appears in the Database window.</ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce the Behavior
CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

<ol> Start Access 2002, and then open the sample database Northwind.mdb.</li> Create a new query that is based on the Invoices query and include all fields.</li> Add the following criteria to the OrderID field in the new query:

In (10248, 10249, 10250)

</li> Save the query as qryThreeInvoices .</li> Open the Invoice report in Design view, and then change the RecordSource property of the report to qryThreeInvoices.</li> On the File menu, click Save As, click Data Access Page in the As drop-down list, and then click OK. Click OK when you are prompted for a file name.

Note that the all fields on the data access page are bound.</li> Open the data access page in Design view.</li> Right-click the page, and then click Page Properties.</li> Click the Data tab, and then change the UseXMLData property to True.</li> On the Tools menu, point to Macro, and then click Visual Basic Editor.</li> In the Immediate window, type the following line, and then press ENTER:

DataAccessPages(0).MSODSC.ExportXML

</li> Return to Access, view the page in Page view, and note that only fields in the details section are bound.</li></ol>

Additional query words: pra

Keywords: kbbug kbdap kbnofix KB287445

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.