ACC: Starting Another Application from a Text Box on a Form

Last reviewed: October 24, 1997
Article ID: Q109705
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Novice: Requires knowledge of the user interface on single-user computers.

This article describes how you can start another application from a text box on a Microsoft Access form.

NOTE: This article explains a technique demonstrated in the sample files, FrmSampl.exe (for Microsoft Access for Windows 95 version 7.0) and FrmSmp97.exe (for Microsoft Access 97). For information about how to obtain these sample files, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q150895
   TITLE     : ACC95: Microsoft Access Sample Forms Available on MSL

   ARTICLE-ID: Q175066
   TITLE     : ACC97: Microsoft Access 97 Sample Forms Available on MSL

MORE INFORMATION

You can start another application from a text box on a form by attaching a RunApp action to the text box's AfterUpdate property. The example below demonstrates how to start an application and load the file whose file name was typed in the text box. This example will start the Microsoft Word for Windows application and load the file from the Word for Windows folder:

  1. Create the following new macro and save it as Open Word:

    NOTE: In the following example, an underscore (_) is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this example.

          RunApp
          -------------------------------------------------------
          Command Line: ="c:\winword\winword.exe c:\winword\" & _
          Forms![formname]![controlname] & ".doc"
    

    NOTE: This example assumes you have the Word for Windows application in a Winword folder on drive C on your computer. Make the appropriate changes to the example line above to point to the correct drive and folder for your computer.

    NOTE: Microsoft Access 7.0 and 97 support long file names. If you are using long file names that contain spaces you will need to concatenate double quotation marks around what you are trying to run or open as shown in the following example:

          RunApp
          -------------------------------------------------------------
          Command Line: ="c:\msoffice\winword\winword.exe " & Chr(34) & _
          "c:\my documents\mydoc" & ".doc" & Chr(34)
    

  2. Add a text box to a form.

  3. Set the text box's AfterUpdate property to the Open Word macro.

  4. View the form in Form view.

  5. Type the name of a file that is in your Word for Windows folder in the text box without the .doc extension, and then press ENTER. For example, for a file named Test.doc you would type "test" (without the quotation marks) in the text box.

REFERENCES

For more information about "RunApp action", search the Help Index for "RunApp," or ask the Microsoft Access 97 Office Assistant.

Keywords          : FmsEvnt kbusage
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.