How to bind a Data Access Page to XML in Access 2002 (281863)
The information in this article applies to:
This article was previously published under Q281863 Moderate: Requires basic macro, coding, and interoperability
skills. This article applies to a Microsoft Access database (.mdb) and to a
Microsoft Access project (.adp). IN THIS TASKSUMMARY This article shows you how to bind a data access page to
XML to create a read-only view of the page. Data access pages can be
bound to an external XML file or to XML embedded on the page. Embedded XML is
also referred to as an XML data island. To bind the page to XML, you must set
several new properties of the DataSourceControl in the Access user interface.
In addition, you must call the ExportXML method of the DataSourceControl to create the XML for the page to
be bound.
back to the top
Binding a Data Access Page to an XML Data Island- Start Access 2002, and then open the sample database
Northwind.mdb.
- In the Database window, click the Customers table.
- On the Insert menu, click Reports.
- Click AutoPage: Columnar, and then click OK. After the page opens, click Design View on the View menu to open the page in Design view.
- Right-click the page, and then click Page Properties. Click the Data tab.
- Change the UseXMLData property to True. This instructs the DataSourceControl on the page to bind to an
XML source.
- On the Tools menu, point to Macro, and then click Visual Basic Editor.
- In the Immediate window, type the following line, and then
press ENTER:
DataAccessPages(0).MSODSC.ExportXML
- View the page in Page view, and note that the controls are
read-only.
If you view the source of the page, you should see XML
that begins:
<XML id=DSCXMLdata>
<DscPersistence>
<Recordsets>
<Customers>
<CustomerID>ALFKI</CustomerID>
<CompanyName>Alfreds Futterkiste</CompanyName>
<ContactName>Maria Anders</ContactName>
<ContactTitle>Sales Representative</ContactTitle>
<Address>Obere Str. 57</Address>
<City>Berlin</City>
<PostalCode>12209</PostalCode>
<Country>Germany</Country>
<Phone>030-0074321</Phone>
<Fax>030-0076545</Fax>
</Customers>
- If you want to change the id for the data island to something other than DSCXMLdata, you can change the XMLDataTarget property of the page to be the name that you choose.
back to the top
Binding a Data Access Page to an External XML File- Start Access 2002, and then open the sample database
Northwind.mdb.
- In the Database window, click the Customers table.
- On the Insert menu, click Reports.
- Click AutoPage: Columnar, and then click OK. After the page opens, click Design View on the View menu to open the page in Design view .
- Right-click the page, and then click Page Properties. Click the Data tab.
- Change the UseXMLData property to True. This instructs the DataSourceControl on the page to bind to an
XML source.
- Change the XMLLocation property to dscXMLDataFile.
- Change the XMLDataTarget property to a local or network path. The file name should use an
.XML extension. This cannot be an HTTP path.
- On the Tools menu, point to Macro, and then click Visual Basic Editor.
- In the Immediate window, type the following line, and then
press ENTER:
DataAccessPages(0).MSODSC.ExportXML
- View the page in Page view, and note that the controls are
read-only.
back to the top
Modification Type: | Minor | Last Reviewed: | 8/11/2004 |
---|
Keywords: | kbDAP kbHOWTOmaster KB281863 kbAudITPro |
---|
|