Microsoft KB Archive/291803

= How to simulate a subform or a subreport on a data access page in Microsoft Access =

Article ID: 291803

Article Last Modified on 9/27/2006

-

APPLIES TO


 * Microsoft Office Access 2003
 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q291803



Moderate: Requires basic macro, coding, and interoperability skills.

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

For a Microsoft Access 2000 version of this article, see 232566.



SUMMARY
This article demonstrates four methods that you can use to simulate a subform or a subreport on a data access page. There is no subpage control in the toolbox in Design view of a page. Therefore, these methods demonstrate how to imitate this behavior with a group, a frameset, hyperlinks, and inline frames.



Using a Group
In this method, you create a grouped page. You can easily create this page by using the Page Wizard; however, if you create the grouped page by using the wizard, the page will not be updateable. Alternatively, you can create a grouped page manually. If you create the grouped page manually, the page will be updateable in most cases.

Using the Page Wizard
 Place a copy of the sample database Northwind.mdb in a folder on the Web server or in a shared network folder. Open the copy of Northwind.mdb from the Web folder or network share.

NOTE: Do not use a mapped drive letter unless everyone uses that same drive letter. In the Database window, click Pages under Objects, and then click New. In the New Data Access Page dialog box, click Page Wizard, and then click OK. Add the OrderID, ShipName, and OrderDate fields from the Orders table. Add the Quantity field from the Order Details table and the ProductName field from the Products table, and then click Next. Click OrderID in the list, and then click the > button to group the page by the OrderID field. Click Finish.</li> Move the ShipName and OrderDate fields into the Header: Products-OrderID section to make the page look more like those in the other three methods.</li> Right-click in the Header: OrdersWiz section, and then click Group Level Properties.</li> Set the Data Page Size property to 5.</li> On the File menu, click Save.</li> In the Save As Data Access Page dialog box, click Web Folders under Save in. In the File name box, type the following:

http:// / /dapGroupWiz.htm

</li> Click Save.</li> On the View menu, click Page View. You can also open the dapGroup.htm page with Microsoft Internet Explorer.</li> Click the Expand control (+) to see the details of each order.</li></ol>

Creating the Page Manually
<ol> Open the shared copy of Northwind.mdb that you created in step 1 of the &quot;Using the Page Wizard&quot; section.</li> In the Database window, click Pages under Objects, and then click New. Do not select anything in the Choose the table or query where the object's data comes from box, and then click OK.</li> In the toolbox, make sure that the Control Wizards are enabled.</li> In the field list, double-click OrderID, ShipName, and OrderDate to add them to the page.</li> In the field list, expand Related Tables, and then drag Order Details to the page beneath the Header: Orders section. Before releasing the mouse button, you should see a section added that says Create a new section below Orders.</li> Click Tabular in the Layout Wizard, and then click OK.</li> Right-click in the Header: Orders section, and then click Group Level Properties. Change the DataPageSize property to 1.</li> On the File menu, click Save.</li> <li>In the Save As Data Access Page dialog box, click Web Folders under Save in. In the File name box, type the following:

http:// / /dapGroupWiz.htm

</li> <li>Click Save.</li> <li>On the View menu, click Page View. You can also open the dapGroup.htm page with Microsoft Internet Explorer.</li> <li>Click the Expand control (+) to see the details of each order.</li></ol>

Create Sample Pages
Follow the steps in this section if you plan to use a frameset, a hyperlink, or inline frames. These steps create the sample main pages dapFrameset.htm, dapHyperlink.htm, and dapIFrame.htm. They also demonstrate how to create a dependent page, dapOrderDetails.htm, that you link to the main pages. <ol> <li>Open the shared copy of Northwind.mdb that you created in step 1 of the &quot;Using the Page Wizard&quot; section.</li> <li>Create a new page in Design view that is based on the Orders table, and then add the following fields from the field list to the page: <ul> <li>OrderID</li> <li>ShipName</li> <li>OrderDate</li></ul>

</li> <li>On the File menu, click Save.</li> <li>In the Save As Data Access Page dialog box, click Web Folders under Save in. In the File name box, type the following:

http:// / /dapFrameset.htm

</li> <li>Click Save.</li> <li>On the File menu, click Save As.</li> <li>In the Save As dialog box, type dapHyperlink, and then click OK.</li> <li>In the Save As Data Access Page dialog box, make sure the Save in list is still pointing to  on  . In the File name box, type dapHyperlink.htm, and then click Save.</li> <li>Repeat steps 6 through 8, but use dapIFrame instead of dapHyperlink.</li> <li>Create a new page that is based on the Order Details table in Design view, and then add the Quantity field from the field list to the page.</li> <li>Under the Order Details table, expand Related Tables, and then add the ProductName field from the Products table.</li> <li>Right-click the page, and then click Group Level Properties. Set the DataPageSize property to 5.</li> <li>On the File menu, click Save.</li> <li>In the Save As Data Access Page dialog box, click Web Folders under Save in. In the File name box, type the following:

http:// / /dapOrderDetails.htm

</li> <li>Click Save.</li> <li>Close any open pages.</li></ol>

Using a Frameset
In this method, you create an HTML file with a frameset that points to the dapFrameset.htm and dapOrderDetails.htm pages. This method provides the most flexibility by allowing you to see both pages at one time, to update the records in these pages, and to edit the design of these pages within Access. <ol> <li>Open the shared copy of Northwind.mdb that you created in step 1 of the &quot;Using the Page Wizard&quot; section.</li> <li>In the Database window, click the dapFrameset.htm page, and then click Design.</li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li> Click MSODSC in the Client Objects & Events box. Click Current in the Event box.IMPORTANT: When you create VBScript blocks for MSODSC events, you must add a parameter to the event name as follows:

<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>

The <I>oEventInfo</I> parameter returns specific information about the event to the script. You must add this parameter, whether or not it will be used, because the script will not work without it.

<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>

</SCRIPT> </li> <li>On the File menu, click Save.</li> <li>On the File menu, click Exit to return to Access.</li> <li> Using an HTML or text editor, create the following HTML page: <HTML> <FRAMESET ROWS=&quot;50%, 50%&quot;> <FRAME ID=&quot;TopFrm&quot; NAME=&quot;Top&quot; SRC=&quot;dapFrameset.htm&quot;> <FRAME ID=&quot;BotFrm&quot; NAME=&quot;Bottom&quot;> </FRAMESET> </HTML> </li> <li>Save this file as OrdersFrameset.htm in the same folder on the Web server.</li> <li>Use Microsoft Internet Explorer to open OrdersFrameset.htm.</li></ol>

Using a Hyperlink
In this method, you create a hyperlink on the dapHyperlink.htm page that applies a filter before opening the dapOrderDetails.htm page. With this method, you can update records in both pages and modify the design of the pages. However, you cannot easily view both pages at the same time.
 * 1) Open the shared copy of Northwind.mdb that you created in step 1 of the &quot;Using the Page Wizard&quot; section.
 * 2) In the Database window, click the dapHyperlink.htm page, and then click Design.
 * 3) Click the Header: Orders section.
 * 4) On the Insert menu, click Hyperlink.
 * 5) In the Insert Hyperlink dialog box, click Page in This Database under Link to, and then click dapOrderDetails. In the Text to display box, type Show Details . Click the Server Filter button, and in the Filter criteria for the data access page box, type OrderID=[OrderID], and then click OK twice to close the Insert Hyperlink dialog box.
 * 6) On the File menu, click Save.
 * 7) On the View menu, click Page View. You can also open the dapHyperlink.htm page with Microsoft Internet Explorer.
 * 8) Click Show Details.

Using an Inline Frame
In this method, you modify the dapIFrame.htm page to include an inline frame that points to the dapOrderDetails.htm page. This method provides the flexibility of allowing you to see both pages at one time and to update the records. <ol> <li>Open the shared copy of Northwind.mdb that you created in step 1 of the &quot;Using the Page Wizard&quot; section.</li> <li>In the Database window, click the dapIFrame page, and then click Design.</li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li> Click MSODSC in the Client Objects & Events box. Click Current in the Event box.IMPORTANT: When you create VBScript blocks for MSODSC events, you must add a parameter to the event name as follows:

<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>

The <I>oEventInfo</I> parameter returns specific information about the event to the script. You must add this parameter, whether or not it will be used, because the script will not work without it.

<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(oEventInfo)>

</SCRIPT> </li> <li>On the File menu, click Save.</li> <li> Add the following HTML code just before the closing BODY tag. <IFRAME ID=&quot;IFrm&quot; HEIGHT=45% WIDTH=80%></IFRAME> </li> <li>On the File menu, click Save.</li> <li>On the File menu, click Exit.</li> <li>Use Microsoft Internet Explorer to open the dapIFrame.htm page.</li></ol>

Additional query words: OfficeKBHowTo emulate mainpage main page subpage sub URL URLs inf ACC2002 reviewdocid

Keywords: kbprogramming kbscript kbdapscript kbhowto KB291803

-

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

© Microsoft Corporation. All rights reserved.