I have an Access web database
- In this database, I have a web form with a button on it
- In its on-click event macro, it calls
RunMacro Macro1
(client-macro) which fires successfully - in Macro1, if I call
RunCode Function Name: DoTest()
it returns the error: "The function you entered can't be used in this expression... Error Number 2426 (or 2950 if I have an "=" symbol in front of my function)
This issue is easily reproduced by doing these steps:
- Create a blank web database in MS Access
- Add and save a table
- Create a default form from that table and put a button on it
Create a new VBA module "Module1" and put the following function in it:
Public Function DoTest() MsgBox "Test function runs smoothly" End Function
- Create a client-macro "Macro1" with
RunCode: Function Name: DoTest()
(Note that IntelliSense recognizes the macro, and it runs fine from here) - Create the form's button's on-click macro event
RunMacro: Macro Name: Macro1
- Click the form's button from form-view to receive the error:
The function you entered can't be used in this expression.
- You may have used a DoEvents, LBound, UBound, Spc, or Tab function in an expression.
- You may have used an aggregate function, such as Count, in a design grid or in a calculated control or field.
Clicking "Ok" shows error number 2426 or 2950 depending on if you have an equals sign before your function name or not in the client-side macro's RunCode command.
I've tried all of the tips from this very similar question without any luck. Access seems to find the function fine, as replacing the function name with gibberish gives a very different error.
What the heck am I doing wrong?
In my actual web database which uses Access Services published to SharePoint 2010, I use an If IsClient() Then
macro statement on the form's button's on-click event to ensure that the VBA is only running in the client mode, but that is not relevant to the error I'm receiving.