Microsoft KB Archive/232566

= ACC2000: How to Simulate a Subform or Subreport on a Data Access Page =

Article ID: 232566

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q232566



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 four methods that you can use to simulate a subform or 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 frameset, hyperlinks, inline frames, and groups.



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.  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. Create a new page based on the Orders table in Design view and add the following fields from the Field List box to the page:  OrderID ShipName OrderDate</li></ul>

</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:// / /dapFrameset.htm

</li> Click Save.</li> On the File menu, click Save As.</li> In the Save As dialog box, type dapHyperlink and click OK.</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> Repeat steps 7 through 9, but use dapIFrame instead of dapHyperlink.</li> Create a new page based on the Order Details table in Design view and add the Quantity field from the Field List box to the page.</li> Under the Order Details table, expand the Related Tables and add the ProductName field from the Products table.</li> Open the Sorting and Grouping dialog box and set the Data Page Size for the Order Details group to 5.

NOTE: Once you set the Data Page Size to a number greater than 1, you can no longer update or add records on that Page.</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:// / /dapOrderDetails.htm

</li> Click Save.</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> Open the shared copy of Northwind.mdb that you created in step 1 of the "Create Sample Pages" section.</li> In the Database window, select 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> Using the Script Outline, insert the following script: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(para)>

</SCRIPT> </li> <li>On the File menu, click Save.</li> <li>On the File menu, click Exit.</li> <li> Using an HTML or text editor, create the following HTML page: <HTML> <FRAMESET ROWS="50%, 50%"> <FRAME ID="TopFrm" NAME="Top" SRC="dapFrameset.htm"> <FRAME ID="BotFrm" NAME="Bottom"> </FRAMESET> </HTML> </li> <li>Save this file as OrdersFrameset.htm in the same folder on the Web server.

NOTE: Because OrdersFrameset.htm contains a frameset, you cannot edit the page inside Access.</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 "Create Sample Pages" section.
 * 2) In the Database window, select the dapHyperlink.htm page, and then click Design.
 * 3) Select 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 . In the Filter criteria for the data access page box, type OrderID=[OrderID], and then click OK.
 * 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 update the records. However, once you add the inline frame to the dapIFrame.htm page, you are unable to open the page directly from Access. <ol> <li>Open the shared copy of Northwind.mdb that you created in step 1 of the "Create Sample Pages" section.</li> <li>In the Database window, select the dapIFrame page, and then click Design.</li> <li>On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li> Using the Script Outline, insert the following script: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(para)>

</SCRIPT> </li> <li>On the File menu, click Save.</li> <li> Add the following HTML code just before the closing BODY tag. <IFRAME ID="IFrm" HEIGHT=45% WIDTH=80%></IFRAME> NOTE: You need to use a text or HTML editor to remove or comment this line before you can open the page from within Access.

</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>

Using a Group
In this method, you create a grouped page. You can easily create this page by using the Page Wizard. However, you cannot update records on the page created with this method. <ol> <li>Open the shared copy of the sample database Northwind.mdb.</li> <li>In the Database window, click Pages under Objects. Click New.</li> <li>In the New Data Access Page dialog box, click Page Wizard, and then click OK.</li> <li>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. Click Next.</li> <li>Select OrderID in the list, and then click the > button to group the page by the OrderID field. Click Finish.</li> <li>You can 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> <li>Open the Sorting and Grouping dialog box and select the OrdersWiz group from the list.</li> <li>Set the Data Page Size to 5.

NOTE: Once you set the Data Page Size to a number greater than 1, you can no longer update or add records on that Page.</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:// / /dapGroup.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 (the plus "+" sign) to see the details of each order.</li></ol>

Additional query words: emulate mainpage main page subpage sub URL URLs form report

Keywords: kbhowto kbdap kbdapscript KB232566

-

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

© Microsoft Corporation. All rights reserved.