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.
- 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.
- Click the page title placeholder Click here and type title text, and then type Products.
- Close and save the page as Products.htm in the wwwroot folder.
- 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.
- Click the page title placeholder Click here and type title text, and then type Order Details.
- Save the page as OrderDetails.htm in the wwwroot folder.
- With the OrderDetails page still open in Design view, start Microsoft Script Editor.
- On the HTML menu, point to Script Block, and then click Client.
- Type the following script:
<SCRIPT language=vbscript>
<!--
Dim intID
Dim objPage
-->
</SCRIPT>
- In the Script Outline, expand Window, and double-click onload.
- 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>
- In the Script Outline, expand MSODSC, and double-click Current.
- 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>
- Close and save the changes that you made to the OrderDetails page.
- Open the Products page in Design view.
- 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>
- 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. - 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.