Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS Access RunCode Macro cannot find my procedure

Tags:

I'm only posting this since I wasn't able to find a solution anywhere. I finally figured it out. Kind of silly really.

When using the RunCode property within an Access Macro, I was trying to run a Sub from my global module. I was getting the error "The expression you entered has a function name that database can't find." I couldn't figure out what the issue was. I followed the advice of everyone that posted on this issue, which was mostly the following:

  1. Use () at the end of the procedure name
  2. DO NOT use the "=" before the procedure name

Still didn't work!

like image 671
MultiGuy Avatar asked Jun 21 '13 22:06

MultiGuy


People also ask

How do you fix a macro in Access?

To edit a standalone macro in Access, right-click the name of the macro to edit in the Navigation Pane. Then select the “Design View” command in the pop-up menu that appears to open the macro design view window. In this view, change the macro actions and arguments, as needed, and then save it again.

How can you run a sub macro saved in a macro Access?

To execute a named submacro within a macro object from an event property or a RunMacro action, enter the name of the macro object, a period, and then the name of the submacro. For example, to execute the PrintIt submacro set of actions in the DoReport macro, enter DoReport.

How do I unblock a macro in Access?

Step 1 – Launch MS Access. Click on “Options”: Step 2 – Click on “Trust Center”, then on “Trust Center Settings”, “Macro settings”, select “Enable all macros” and click OK: Step 3 – Exit MS Access.


1 Answers

THEN I read the error message carefully. It mentions that it could not find the FUNCTION name. Apparently, the RunCode property specifically requires a "Function" not a Sub. So, I simply changed my Sub to Function and it worked fine!

Hope this helps.

like image 51
MultiGuy Avatar answered Oct 29 '22 05:10

MultiGuy