Calling a Function from Macro Design In Access
ms-access, ms-access-2007, vba
Solution
Make sure your VBA code is placed inside a Function (not a SUB, that won't work). Create your function like:
Function DoSomething()
'Do your stuff
End Function
Or if you want to execute a Sub, just create a Function that calls your sub, like:
Function DoSomething()
Call YourSub()
End Function
Inside the Macro Design, add the 'RunCode' action (Macro Commands > RunCode) and call your function:
DoSomething()
And voila, you're done.
Problem
I have written some sql queries, some sub procedures and have some saved imports. Now I am trying to use the Macro Design in Access to provide a run button which will run these objects sequentially. However I dont see any command for running a sun procedure, I can see OpenVisualBasicModule and Runcode. OpenVisualBaicModule is only opening my sub procedures and Run Code is asking for a function only. I created a function with all the sub procedure call inside. But thats not working while individually all of them work. Any suggestion what to do.