ACC2002: Cannot Bind a Grouped Report That Was Saved as a Data Access Page to XML (287445)
The information in this article applies to:
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.
- Start Access 2002, and then open the database that contains your page.
- Click your data access page in the Database window, and then open it in Design view.
- On the View menu, click Data Outline to view the data model for the page.
- 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]
- Remove the brackets from the Name property of the page field.
- 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, "[") > 0 Then
' remove the brackets and rename the PageField
strNewName = Mid(pgf.Name, 2, InStr(2, pgf.Name, "]") - 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 "Page fields with brackets have been renamed"
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 "Cannot find the specified page: " & vbCrLf & vbCrLf & strPageName, vbInformation
Resume RemoveBracketExit
Else
MsgBox "An error has occurred: " & vbCrLf & _
Err.Description & vbCrLf & _
"number: " & 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 "NameOfDataAccessPage"
where NameOfDataAccessPage is the name of your page as it appears in the Database window.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
| Modification Type: | Minor | Last Reviewed: | 9/27/2006 |
|---|
| Keywords: | kbbug kbDAP kbnofix KB287445 |
|---|
|