Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 234303 - Last Review: June 29, 2004 - Revision: 2.0
ACC2000: How to Start Another Application from a Data Access Page
This article was previously published under Q234303
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).
This article shows you how to start another application from a Microsoft Access data access page.
The following example demonstrates how to start an application and to load a file whose name you type in a text box. This example starts Microsoft Word for Windows and loads a document that you specify.
- Start Microsoft Access, and open any database.
- In the Database window, click Pages under Objects, and then click New.
- In the New Data Access Page box, click Design View, and then click OK.
- Place a text box in the Section: Unbound section of the page.
- Set the following properties for the text box:
Id: txtApp
Left: 2in
Top: 0.5in
Width: 1in
- Set the following properties for the text box label:
FontWeight: bold
InnerText: Application Name:
Left: 0in
TextAlign: right
Top: 0.5in
Width: 2in
- Place another text box in the Section: Unbound section of the page.
- Set the following properties for this text box:
Id: txtDoc
Left: 2in
Top: 0.75in
Width: 4in
- Set the following properties for the text box label:
FontWeight: bold
InnerText: Path and File Name:
Left: 0in
TextAlign: right
Top: 0.75in
Width: 2in
- Place a command button in the Section: Unbound section of the page.
- Set the following properties for the command button:
Id: cmdOpenApp
FontWeight: bold
InnerText: Open App
Left: 2.5in
Top: 1in
- Place another command button in the Section: Unbound section of the page.
- Set the following properties for the command button:
Id: cmdCloseApp
FontWeight: bold
InnerText: Close App
Left: 2.5in
Top: 1.25in
- On the File menu, click Save, and save the page as LaunchApp.htm. Make a note of the folder where this file is saved. You will need this information later in these steps.
- On the Tools menu, point to Macro, and then click Microsoft Script Editor.
- On the HTML menu, point to Script Block, and then click Client. Insert the following script:
<SCRIPT language=vbscript>
<!--
Option Explicit
Dim Obj
-->
</SCRIPT>
- Using the Script Outline, insert the following script for the OnClick event of the cmdOpenApp command button:
<SCRIPT event=onclick for=cmdOpenApp language=vbscript>
<!--
Dim strApp, strDoc
Dim intPosition
strApp = document.all.item("txtApp").Value
strDoc = document.all.item("txtDoc").Value
If Not IsNull(strApp) And strApp <> "" Then
Set Obj = CreateObject(strApp & ".Application")
Obj.Application.Visible = True
Else
MsgBox "Must enter an Application Name."
Exit Sub
End If
If Not IsNull(strDoc) and strDoc <> "" Then
Select Case UCase(StrApp)
Case "ACCESS"
Obj.OpenCurrentDatabase strDoc
Case "EXCEL"
Obj.Workbooks.Open strDoc
Case "WORD"
Obj.Documents.Open strDoc
Case Else
MsgBox "Application Unknown."
Exit Sub
End Select
End If
-->
</SCRIPT>
- Using the Script Outline, insert the following script for the OnClick event of the cmdCloseApp command button:
<SCRIPT event=onclick for=cmdCloseApp language=vbscript>
<!--
Obj.Application.Quit
Set Obj = Nothing
-->
</SCRIPT>
- Close the Microsoft Script Editor and Microsoft Access, and when prompted, click Yes to save changes.
- Start Microsoft Internet Explorer 5 or later.
- On the File menu, click Open.
- Click Browse and locate the folder where the LaunchApp.htm file is stored.
- Click LaunchApp.htm and click Open.
- Click OK and type Word in the Application Name text box.
- In the next text box, type a path and file name to some Word document, such as C:\Windows\Script.doc.
- Click Open App. Note that Word starts and opens the document that you specified.
- Click Close App to quit Word.
APPLIES TO
- Microsoft Access 2000 Standard Edition
| kbhowto kbdap kbdapscript KB234303 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate