ACC: How to Start a Macro from a Combo Box List of NamesID: Q117910
|
Moderate: Requires basic macro, coding, and interoperability skills.
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.
The following steps describe how to create a combo box or list box that you
can use to start a macro, a function, or another Windows-based application:
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
Item ItemType
------------------------------
macro Macro
function Function
Windows application App
For example, you might create the following entries in the table:
ItemName ItemDescription ItemType
-------------------------------------------------------
C:\WINDOWS\CALC.EXE Run Windows Calculator App
Notepad Run Windows Notepad App
Macro1 Run Macro 1 Macro
MyFunc() Run MyFunc() Function
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.Main
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]![cboSelect]
RunCode
FunctionName: =Forms![MyForm]![cboSelect]
RunApp
ApplicationName: =Forms![MyForm]![cboSelect]
For more information about using a combo box, search the Help Index for
"creating combo boxes," or ask the Microsoft Access 97 Office
Assistant.
For more information about using a list box, search the Help Index for
"creating list boxes," or ask the Microsoft Access 97 Office Assistant.
Keywords : kbusage McrOthr
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 6, 1999