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:
Still didn't work!
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With