Results 1 to 7 of 7
  1. #1
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283

    Running Macro from Combobox using Command Button

    Hey guys,



    I have a combobox with multiple different macros to choose from, and I'm trying to make it so when the user selects a macro from the combobox and presses the command button the macro will run. The only way I can think about making this work is using case statements for all the macros, but I'm just wondering if there is an easier way.

    Thanks!

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    in the combo after update event put

    docmd.runmacro me.comboname

  3. #3
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    sorry - that code should go in your button click event

  4. #4
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283
    Shouldn't I put that in the command button? Sorry this is the first time I've ever done this before. What should the row source type be? or shouldn't there be one? Do I have to write code for the combobox to put the values in then DoCmd.RunMacro in the command button?

  5. #5
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283
    Nevermind I figured it out! Thank you

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Yes - I posted a second post to correct it

    you said 'I have a combobox with multiple different macros to choose from' So I assumed you already had a solution to this question

    What should the row source type be? or shouldn't there be one?
    However I would suggest you make the rowsourcetype 'value list' and in the rowsource enter the names of your macros separated by a semi colon - macro1;macro2;macro3 etc

    Do I have to write code for the combobox to put the values in
    no
    then DoCmd.RunMacro in the command button?
    yes - as previously advised

  7. #7
    MTSPEER is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    283
    Thank you sir!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-12-2014, 06:09 AM
  2. Command Button to Run Macro, can't find macro
    By Ace2014 in forum Modules
    Replies: 22
    Last Post: 06-11-2014, 11:42 AM
  3. Replies: 3
    Last Post: 08-04-2013, 07:11 AM
  4. Replies: 4
    Last Post: 05-06-2013, 12:56 PM
  5. Replies: 1
    Last Post: 07-27-2010, 02:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums