Help and Support
 

powered byLive Search

ACC: How to Start a Macro from a Combo Box List of Names

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:117910
Last Review:January 19, 2007
Revision:2.1
This article was previously published under Q117910
Moderate: Requires basic macro, coding, and interoperability skills.

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.

Back to the top

MORE INFORMATION

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:
1.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
						
2.Fill the table you created in step 1 with the macros, functions, and Windows-based applications that you want to be 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
      -------------------------------------------------------
      C:\WINDOWS\CALC.EXE   Run Windows Calculator   App
      Notepad               Run Windows Notepad      App
      Macro1                Run Macro 1              Macro
      MyFunc()              Run MyFunc()             Function
						
3.Create a new, blank form.
4.Add a combo box or list box with the following properties to the form:
      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
						
5.Save the form as MyForm.
6.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]![cboSelect]
      RunCode
         FunctionName: =Forms![MyForm]![cboSelect]
      RunApp
         ApplicationName: =Forms![MyForm]![cboSelect]
						
7.View the MyForm form in Form view. Select any entry in the combo box or list box to start the associated item.

Back to the top

REFERENCES

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.

Back to the top


APPLIES TO
Microsoft Access 1.0 Standard Edition
Microsoft Access 1.1 Standard Edition
Microsoft Access 2.0 Standard Edition
Microsoft Access 95 Standard Edition
Microsoft Access 97 Standard Edition

Back to the top

Keywords: 
kbhowto kbusage KB117910

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.