Microsoft KB Archive/304235

= ACC2002: How to Determine If a Page Is Open in Access or Internet Explorer =

Article ID: 304235

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q304235



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 describes how to use the HTML document object model to determine if a data access page is open in Microsoft Access or Microsoft Internet Explorer.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Sample Code
 Start Microsoft Access. On the Help menu, point to Sample Databases, and then click Northwind Sample Database. Close the Switchboard form when it appears. In the Database window, click Pages under Objects, and then click New. In the New Data Access Page dialog box, click AutoPage: Columnar. In the Choose the table or query where the object's data comes from list, click Customers, and then click OK. Save the new page as Customers.htm to a local path on your computer. On the View menu, click Design View.</li> If the Toolbox is not displayed, click Toolbox on the View menu.</li>  Add a command button to the page, and then set the following properties for the command button: <pre class="fixed_text">  ID: cmdOpenWhere InnerText: Open Where </li> On the Tools menu, point to Macro, and then click Microsoft Script Editor.</li> In the Client Objects & Events list, click cmdOpenWhere, and then click onclick in the Events list.</li>  Type the following code between the <SCRIPT> tags: Dim strLocation

' Use window.location.protocol to get the protocol for the current page. strLocation = window.location.protocol

Select Case strLocation Case &quot;http:&quot;, &quot;https:&quot;, &quot;ftp:&quot; MsgBox &quot;This page is open in Internet Explorer using an Internet protocol.&quot; Case &quot;file:&quot; MsgBox &quot;This page is open in Internet Explorer using a file system path.&quot; Case &quot;accdp:&quot; MsgBox &quot;This page is open in Microsoft Access.&quot; Case Else MsgBox &quot;Cannot determine protocol.&quot; End Select </li> On the File menu, click Exit. Save your changes when you are prompted to do so.</li> Test the page by using any of the following methods: <ul> On the View menu, click Page View. Click the command button to test the page.</li> Open the folder where the page is saved, and double-click the page to open it. Click the command button to test the page.</li> If you have a Web server, copy the page from your local computer to the Web server, and open the page by using the Hypertext Transfer Protocol (http) address for the page. Click the command button to test the page.</li></ul> </li></ol>

<div class="references_section">