ACC2000: How to Simulate a Subform or Subreport on a Data Access Page
ID: Q232566
|
The information in this article applies to:
Moderate: Requires basic macro, coding, and interoperability skills.
This article applies to a Microsoft Access database (.mdb) and 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.
MORE INFORMATIONCreate 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
- On the File menu, click Save.
- In the Save As Data Access Page dialog box, click Web Folders under Save in. In the File name box, type the following:
http://ServerName/FolderName/dapFrameset.htm -
Click Save.
- On the File menu, click Save As.
- In the Save As dialog box, type
dapHyperlink
and click OK.
- In the Save As Data Access Page dialog box, make sure the Save in list is still pointing to FolderName on ServerName. In the File name box, type dapHyperlink.htm, and then click Save.
- Repeat steps 7 through 9, but use dapIFrame instead of dapHyperlink.
- 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.
- Under the Order Details table, expand the Related Tables and add the ProductName field from the Products table.
- 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.
- On the File menu, click Save.
- In the Save As Data Access Page dialog box, click Web Folders under Save in. In the File name box, type the following:
http://ServerName/FolderName/dapOrderDetails.htm -
Click Save.
- Close any open pages.
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.
- Open the shared copy of Northwind.mdb that you created in step 1 of the "Create Sample Pages" section.
- In the Database window, select the dapFrameset.htm page, and then click Design.
- On the Tools menu, point to Macro, and then click Microsoft Script Editor.
- 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 oEventInfo parameter added above is used to return specific information about the event to the script. You must add this parameter, regardless of whether it will be used or not, because the script won't work without it.
<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(para)>
<!--
dim Loc
dim Ser
Loc = "http://<ServerName>/<FolderName>/dapOrderDetails.htm?serverfilter="
Ser = chr(34) & "Orderid=" & orderid.value & chr(34)
Loc = Loc & Ser
window.parent.frames("BotFrm").location = Loc
-->
</SCRIPT>
- On the File menu, click Save.
- On the File menu, click Exit.
- 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>
- 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.
- Use Microsoft Internet Explorer to open OrdersFrameset.htm.
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.
- Open the shared copy of Northwind.mdb that you created in step 1 of the "Create Sample Pages" section.
- In the Database window, select the dapHyperlink.htm page, and then click Design.
- Select the Header: Orders section.
- On the Insert menu, click Hyperlink.
- 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.
- On the File menu, click Save.
- On the View menu, click Page View. You can also open the dapHyperlink.htm page with Microsoft Internet Explorer.
- 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.
- Open the shared copy of Northwind.mdb that you created in step 1 of the "Create Sample Pages" section.
- In the Database window, select the dapIFrame page, and then click Design.
- On the Tools menu, point to Macro, and then click Microsoft Script Editor.
- 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 oEventInfo parameter added above is used to return specific information about the event to the script. You must add this parameter, regardless of whether it will be used or not, because the script won't work without it.
<SCRIPT LANGUAGE=vbscript FOR=MSODSC EVENT=Current(para)>
<!--
dim Loc
dim Ser
Loc = "http://<ServerName>/<FolderName>/dapOrderDetails.htm?serverfilter="
Ser = chr(34) & "Orderid=" & orderid.value & chr(34)
Loc = Loc & Ser
window.frames("IFrm").location = Loc
-->
</SCRIPT>
- On the File menu, click Save.
- 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.
- On the File menu, click Save.
- On the File menu, click Exit.
- Use Microsoft Internet Explorer to open the dapIFrame.htm page.
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.
- Open the shared copy of the sample database Northwind.mdb.
- In the Database window, click Pages under Objects. 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. Click Next.
- Select OrderID in the list, and then click the > button to group the page by the OrderID field. Click Finish.
- 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.
- Open the Sorting and Grouping dialog box and select the OrdersWiz group from the list.
- 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.
- On the File menu, click Save.
- In the Save As Data Access Page dialog box, click Web Folders under Save in. In the File name box, type the following:
http://ServerName/FolderName/dapGroup.htm -
Click Save.
- On the View menu, click Page View. You can also open the dapGroup.htm page with Microsoft Internet Explorer.
- Click the Expand control (the plus "+" sign) to see the details of each order.
Additional query words:
emulate mainpage main page subpage sub URL URLs
Keywords : AccDAP DAPHowTo DAPScriptHowTo dtavbscript
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
|