ACC2000: How to use VBScript to Synchronize Two Data Access Pages (233487)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q233487
Moderate: Requires basic macro, coding, and interoperability skills.

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

SUMMARY

This article shows you how to use VBScript to synchronize two data access pages. The example in this article uses VBscript to capture the current record that is displayed on the first page, and then to search and move the second page to the matching record.

MORE INFORMATION

The following example uses the Find method of the Recordset object (supplied by the Microsoft Office Data Source Control) to search for a matching record and to display the match while keeping both pages synchronized.

This article assumes that you have Microsoft Web services (Personal Web Server or Internet Information Services) installed correctly, and that the default wwwroot folder exists on your hard disk.
  1. In the sample database Northwind.mdb, create a new data access page that is based on the Products table, and add all of the fields from the Products table to the page.
  2. Click the page title placeholder Click here and type title text, and then type Products.
  3. Close and save the page as Products.htm in the wwwroot folder.
  4. Create a new data access page that is based on the Order Details table, and add all the fields from the Order Details table to the page.
  5. Click the page title placeholder Click here and type title text, and then type Order Details.
  6. Save the page as OrderDetails.htm in the wwwroot folder.
  7. With the OrderDetails page still open in Design view, start Microsoft Script Editor.
  8. On the HTML menu, point to Script Block, and then click Client.
  9. Type the following script:
    <SCRIPT language=vbscript>
    <!--
        Dim intID
        Dim objPage
    -->
    </SCRIPT>
    					
  10. In the Script Outline, expand Window, and double-click onload.
  11. Type the following script and replace <servername> with the actual name of your Web server:
    <SCRIPT event=onload for=window language=vbscript>
    <!--
        Set objPage = window.open("http://<servername>/products.htm")
    -->
    </SCRIPT>
    					
  12. In the Script Outline, expand MSODSC, and double-click Current.
  13. Type the following script. Note how EVENT=Current changes to EVENT=Current(x):
    <SCRIPT event=Current(x) for=MSODSC language=vbscript>
    <!--
        intID = document.all.item("ProductID").value
        objPage.location.reload
    -->
    </SCRIPT>
    					
  14. Close and save the changes that you made to the OrderDetails page.
  15. Open the Products page in Design view.
  16. Start Microsoft Script Editor. In the Script Outline, expand Window, double-click onload, and then enter the following script:
    <SCRIPT event=onload for=window language=vbscript>
    <!--
        MSODSC.DefaultRecordset.Find "[ProductID]=" & window.opener.intID, 0, 1, 1
    -->
    </SCRIPT>
    					
  17. Close and save the Products page, and then use Microsoft Internet Explorer to load http://<servername>/orderdetails.htm, replacing <servername> with the actual name of your Web server.

    Note that two browsers are loaded; the first displays the Order Details page, and the second displays the Products page (you may need to rearrange the pages to see both at the same time). Also note that the ProductID on both pages match.
  18. Move through the records on the Order Details page, and note that the ProductID on the Products page stays synchronized with the ProductID on the Order Details page.

Modification Type:MinorLast Reviewed:7/13/2004
Keywords:kbDAP kbDAPScript kbhowto KB233487