Run Macro From Access Front End

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
I wrote a Macro that Exports data to a temporary workbook, then formats the data, then saves it in a temporary file, then sends it via outlook, then deletes the temporary workbook.

It works great when I use F5 to execute it. How do I save it to a Front End Access Macro

When I try to create a macro. I go to macro ---> RunMacro.

My macro does not appear in the dropdown?? How can I link it?

The macro is in my Access Database code module named modExportData
The Macro is named GetQueryInExcel

Any help would be greatly appreciated.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
You've got caught by a bit of Access terminology.
There are two distinct ways to automate Access: VBA, which you have used here, and Macros, which are not VBA. You can use macros to trigger VBA but as far as I know you can only call a Function, not a Sub.
As an aside... In VBA, if you type DoCmd. you will get a drop-down list with maybe 100 options. They are all Macro commands.

If you want to have a button that runs your code you don't need a macro to do that. Create a command button and cancel the wizard. Then go to the button's Properties and set the Caption (in the Format tab) and the Name (in the Other tab). Now go to the Events tab, double-click the blank line next to Click, and you should see [Event Procedure]. Click the ... button at the right of the line and you'll be in the code module. Put this code in the Click event for your button:
Code:
modExportData.GetQueryInExcel

Denis
 
Upvote 0
SydneyGeek,

Thanks for the help. I was able to get it working because of your explanation!
 
Upvote 0

Forum statistics

Threads
1,221,902
Messages
6,162,726
Members
451,782
Latest member
LizN

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top