There were many good responses in this thread, but the original question does not seem to have been answered. As this is one of the first results that came up in a Google search when I was trying to address this specific issue for myself, I figured I should post what I have figured out that...
I think you had a good idea of how to do it. It happens to be the exact same way I tried to make the escape key work on the reports. Unfortunately the Access designers have some glitch where it throws the 2585 error. I fought this most of yesterday with no luck, but today I struck upon an idea...
This is not an answer to the asker's question, but because I found this thread when I was searching for an answer to my question, I thought I should post the answer I found.
If you happen to be using a function instead of a sub, you must label it with an equals sign at the beginning and...