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

ID: Q109705


The information in this article applies to:


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:

Q150895 ACC95: Microsoft Access Sample Forms Available on MSL

Q175066 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 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 
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: March 30, 1999