ACC2002: Requery Method Does Not Rebind Page to XML Data File (284960)



The information in this article applies to:

  • Microsoft Access 2002

This article was previously published under Q284960
Advanced: Requires expert coding, interoperability, and multiuser skills.

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

SYMPTOMS

If you change data in an XML file to which a data access page is bound, requerying the page through script does not show the updated data. You may see this behavior if the page is bound at run time or by using the user interface.

CAUSE

The Requery method does not destroy the XML data that was created on initial binding. As a result, the XML document object model does not fetch the current data.

RESOLUTION

To work around this behavior, use the Refresh method of the Data Source Control, as follows:
MSODSC.Refresh
				

STATUS

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

MORE INFORMATION

You can bind a data access page to XML data that is embedded on the page (this is known as an XML data island) or to an external XML file. Binding the page to XML creates a read-only page.

Steps to Reproduce the Behavior

  1. Open the sample database Northwind.mdb or the sample project NorthwindCS.adp.
  2. In the Database window, click Pages, and then click New.
  3. In the New Data Access Page dialog box, click AutoPage: Columnar, click the arrow in the Choose the table or query where the object's data comes from box, click Shippers, and then click OK.
  4. On the View menu, click Design View.
  5. Right-click the page, and then click Page Properties on the shortcut menu.
  6. Set the following properties for the page:
       UseXMLData: True
       XMLDataTarget: C:\RequeryTest.xml
       XMLLocation: dscXMLDataFile
    					
  7. Press CTRL+G to open the Immediate window.
  8. Type the following line in the Immediate Window, and then press ENTER:
    DataAccessPages(0).MSODSC.ExportXML
    						
    This code creates the XML file that is specified in the XMLDataTarget property and binds the page to the file.
  9. Add a command button to the page, and then set the following properties for the command button:
       ID: cmdRequery
       InnerText: Requery
    					
  10. On the Tools menu, point to Macro, and then click Microsoft Script Editor.
  11. In the Client Objects & Events box, click cmdRequery in the list. Double-click onclick in the list of events.
  12. Enter the following line in the Script Editor between the SCRIPT tags, and then remove the Return line.
    MSODSC.DataPages(0).Requery
    					
  13. Return to Access, and then save the page as C:\RequeryTest.htm.
  14. View the page in Microsoft Internet Explorer 5 or later.
  15. Click Start, click Run, type notepad C:\RequeryTest.xml in the Run box, and then click OK.
  16. Change Speedy Express to Really Speedy Express, and then save and close the XML file.
  17. Return to the page in Internet Explorer, and then click Requery.
Note that the CompanyName for Speedy Express did not change.

REFERENCES

For additional information about working with XML data from a data access page, click the article number below to view the article in the Microsoft Knowledge Base:

281863 ACC2002: How to Bind a Data Access Page to XML


Modification Type:MajorLast Reviewed:11/6/2003
Keywords:kbbug kbDAP kbDAPScript kbfix KB284960