I have a user defined function defined in a module in an Access 2010 DB that used to work fine when referenced to create a calculated column in a query. Now it has an odd behaviour! When I run the query manually, it works as expected. However, when I run it with a VBA program, it now fails.
After testing, I found that this happens consistently, even if I create a new DB (or if I go back to 2007 and do it there), recreate the function (or ANY function), create a query that will use it, and then create a simple form with a single button that only has the STOP command in the VBA code. If I run the query manually it's fine, but if I leave it open (or rerun it after) and load the form and press the button, the calculated column changes from the real values to #ERROR. Then if I let the button code continue, or stop the code, the values instantly reappear. When the STOP is encountered the function can be successfully called in the Immediate window.
I even tried it with a simple function that returns the length of the string passed in (1 line) and ran it both ways with the same results, so there is nothing wrong with the original function.
Is there something that is causing the function to be inaccessible when code is running? This seems to have been a recent development and I'm starting to wonder if MS put something in in one of the Windows/Office updates.
Any help greatly appreciated.
After testing, I found that this happens consistently, even if I create a new DB (or if I go back to 2007 and do it there), recreate the function (or ANY function), create a query that will use it, and then create a simple form with a single button that only has the STOP command in the VBA code. If I run the query manually it's fine, but if I leave it open (or rerun it after) and load the form and press the button, the calculated column changes from the real values to #ERROR. Then if I let the button code continue, or stop the code, the values instantly reappear. When the STOP is encountered the function can be successfully called in the Immediate window.
I even tried it with a simple function that returns the length of the string passed in (1 line) and ran it both ways with the same results, so there is nothing wrong with the original function.
Is there something that is causing the function to be inaccessible when code is running? This seems to have been a recent development and I'm starting to wonder if MS put something in in one of the Windows/Office updates.
Any help greatly appreciated.