How to bind a Data Access Page to XML in Access 2002 (281863)



The information in this article applies to:

  • Microsoft Access 2002

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

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

  1. Start Access 2002, and then open the sample database Northwind.mdb.
  2. In the Database window, click the Customers table.
  3. On the Insert menu, click Reports.
  4. 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.
  5. Right-click the page, and then click Page Properties. Click the Data tab.
  6. Change the UseXMLData property to True. This instructs the DataSourceControl on the page to bind to an XML source.
  7. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  8. In the Immediate window, type the following line, and then press ENTER:

    DataAccessPages(0).MSODSC.ExportXML

  9. 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>
    					
  10. 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

  1. Start Access 2002, and then open the sample database Northwind.mdb.
  2. In the Database window, click the Customers table.
  3. On the Insert menu, click Reports.
  4. 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 .
  5. Right-click the page, and then click Page Properties. Click the Data tab.
  6. Change the UseXMLData property to True. This instructs the DataSourceControl on the page to bind to an XML source.
  7. Change the XMLLocation property to dscXMLDataFile.
  8. Change the XMLDataTarget property to a local or network path. The file name should use an .XML extension. This cannot be an HTTP path.
  9. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  10. In the Immediate window, type the following line, and then press ENTER:

    DataAccessPages(0).MSODSC.ExportXML

  11. View the page in Page view, and note that the controls are read-only.
back to the top

Modification Type:MinorLast Reviewed:8/11/2004
Keywords:kbDAP kbHOWTOmaster KB281863 kbAudITPro