MS Access RunCode Macro cannot find my procedure

I had a similar issue with the error message. My VBA code had the following declaration:

private function MyFunction()

....

end function

I removed private declaration to get the Macro Runcode to execute the MyFunction()

For example:

Function MyFunction()

End Function

Another solution that worked for me:

The module name can NOT have the same name as the procedure(s) in the module(s).


My mistake was putting the function in a Class Module instead of a regular module.


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.

Tags:

Ms Access

Vba