Microsoft KB Archive/209011

= ACC2000: How to Start Macros, Functions, and Applications from a Combo or List Box =

Article ID: 209011

Article Last Modified on 6/28/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209011



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies only to a Microsoft Access database (.mdb).



SUMMARY
This article describes how to start a macro, a function, or another Microsoft Windows-based application by selecting it from a combo box or list box on a Microsoft Access form.



MORE INFORMATION
To create a combo box or list box that starts a macro, a function, or another Windows-based application, follow these steps:  Start Microsoft Access and create a new, blank database.  Create the following table to supply the combo box or list box with a list of available items:   Table: Activities ---  Field Name: ItemName Data Type: Text Field Size: 50 Field Name: ItemDescription Data Type: Text Field Size: 50 Field Name: ItemType Data Type: Text Field Size: 12   Fill the table that you created in step 2 with the macros, functions, and Windows-based applications that you want to have listed in the combo box or list box. Note that any applications listed in the table must be .com or .exe files. You cannot include .hlp or other non-executable files from a macro. Use the following tags in the ItemType field:   Item                  ItemType --  macro                 Macro function             Function Windows application  App For example, you might create the following entries in the table:   ItemName              ItemDescription          ItemType ---  CALC.EXE              Run Windows Calculator   App Notepad              Run Windows Notepad      App Macro1               Run Macro 1              Macro MyFunc             Run MyFunc             Function  Create a new, blank form.  Add a combo box or list box with the following properties to the form: <pre class="fixed_text">  Combo or List Box ---  Name: cboSelect RowSourceType: Table/Query RowSource: Activities (the table created in step 1) ColumnCount: 3 ColumnWidths: 0; 2; 0 BoundColumn: 1 AfterUpdate: mcrMyForm </li> Save the form as MyForm.</li>  Create a new macro with the following actions. Save the macro as mcrMyForm.NOTE: If the Conditions column is not visible, click Conditions on the View menu. Condition                                        Action --  Forms![MyForm]![cboSelect].Column(2)="Macro"      RunMacro Forms![MyForm]![cboSelect].Column(2)="Function"  RunCode Forms![MyForm]![cboSelect].Column(2)="App"       RunApp

mcrMyForm Actions ---  RunMacro MacroName: =Forms![MyForm]![cboSeFect] RunCode FunctionName: =Forms![MyForm]![cboSelect] RunApp ApplicationName: =Forms![MyForm]![cboSelect] </li> View the MyForm form in Form view. Select any entry in the combo box or list box to start the associated item.</li></ol>

<div class="references_section">