Question posted 2013 · +7 upvotes
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:
- Use () at the end of the procedure name
- DO NOT use the “=” before the procedure name
Still didn’t work!
Accepted answer +15 upvotes
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.
Top access-vba Q&A (6)
- Create a query dynamically through code in MSAccess 2003 [VBA] +19 (2008)
- VBA: Why must I set focus to control every time? +15 (2013)
- Equivalent cURL in VBA? +14 (2013)
- Retrieve column values of the selected row of a multicolumn Access listbox +12 (2011)
- Loop through all unbound controls on a form and clear data +11 (2013)
- Passing arguments to Access Forms created with 'New' +9 (2014)
access-vba solutions on this site
— top 17%.