Microsoft KB Archive/232594

= ACC2000: How to Use a Command Button to Hide and Display a Frame =

Article ID: 232594

Article Last Modified on 6/24/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q232594



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
You can hide and display a frame by using a command button. This article shows you how to create script that hides and displays one frame within a frameset or an inline frame.



MORE INFORMATION
When you use frames to simulate a subform or subreport on a data access page, you may want to provide a command button that toggles whether the frame is visible or not.

For additional information about creating frames on a data access page, please see the following article in the Microsoft Knowledge Base:

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

Creating the Pages
 Open the sample database Northwind.mdb. Create a new page based on the Orders table and add the following fields from the Field List box to the page.  OrderID OrderDate ShipName

</li>  Add a command button to the page with the following properties: <pre class="fixed_text">  Command Button --  Id: cmdToggle Inner Text: Hide Frame </li> Save the page as dapOrdersFrameset.htm to a Web folder on the server.</li> Make a copy of this page, name it dapOrdersIFrame, and save it as dapOrdersIFrame.htm to the same Web folder.</li> Create a new page based on the Order Details table and add the Quantity field from the Field List box to the page.</li> Under the Order Details table in the Field List box expand Related Tables and add the ProductName field from the Products table to the page.</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 one, you can no longer update or add records on that page.</li> Save the page as dapOrderDetails.htm to a Web folder on the server.</li></ol>

Frame Within a Frameset
<ol>  Create the following HTML page: <HTML> <HEAD> <TITLE>Test Page</TITLE> </HEAD> <FRAMESET ID="FSet" ROWS="50%, 50%"> <FRAME NAME="Top" SRC="dapOrdersFrameset.htm"> <FRAME NAME="Bottom"> </FRAMESET> </HTML> </li> Save the page as TestPage.htm in the same folder as dapOrdersFrameset.htm.</li> Open the dapOrdersFrameset.htm page in Design view.</li> On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li>  Using the Script Outline, insert the following script for the Current event of the MSODSC: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>  Using the Script Outline, insert the following script for the OnClick event of the cmdToggle button. <SCRIPT language=vbscript for=cmdToggle event=onclick>

</SCRIPT> </li> Open the TestPage.htm page with Microsoft Internet Explorer. Click the button several times. Note that clicking the command button toggles whether the lower frame is visible or not and that the text on the command button changes.</li></ol>

Inline Frame
<ol> Open the dapOrdersIFrame page in Design view.</li> On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> <li> Add an inline frame tag to the dapOrdersIFrame.htm page, immediately before the closing BODY tag (</BODY>). <IFRAME ID="IFrm" HEIGHT="50%" WIDTH="80%"></IFRAME> </li> <li> Using the Script Outline, insert the following script for the Current event of the MSODSC.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> Using the Script Outline, insert the following script for the OnClick event of the cmdTaggle button. <SCRIPT language=vbscript for=cmdToggle event=onclick>

</SCRIPT> </li> <li>Open the page in Microsoft Internet Explorer. Click the command button several times. Note that clicking the command button toggles whether the inline frame is visible or not and that the text on the command button changes.</li></ol>

Additional query words: subpage hide show

Keywords: kbhowto kbdap kbdapscript KB232594

-

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

© Microsoft Corporation. All rights reserved.