Microsoft KB Archive/281863

= How to bind a Data Access Page to XML in Access 2002 =

Article ID: 281863

Article Last Modified on 8/11/2004

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



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 TASK
SUMMARY
 * Binding a Data Access Page to an XML Data Island
 * Binding a Data Access Page to an External XML File



SUMMARY
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.</li> In the Immediate window, type the following line, and then press ENTER:

DataAccessPages(0).MSODSC.ExportXML

</li>  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> </li> 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.</li></ol>

back to the top

Binding a Data Access Page to an External XML File
<ol> Start Access 2002, and then open the sample database Northwind.mdb.</li> In the Database window, click the Customers table.</li> On the Insert menu, click Reports.</li> 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 .</li> Right-click the page, and then click Page Properties. Click the Data tab.</li> Change the UseXMLData property to True. This instructs the DataSourceControl on the page to bind to an XML source.</li> Change the XMLLocation property to dscXMLDataFile.</li> Change the XMLDataTarget property to a local or network path. The file name should use an .XML extension. This cannot be an HTTP path.</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> View the page in Page view, and note that the controls are read-only.</li></ol>

back to the top

Additional query words: OfficeKBHowTo inf

Keywords: kbhowtomaster kbdap KB281863

-

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

© Microsoft Corporation. All rights reserved.