Asked by:
Can Not set a Public Function in a Data Macro using setLocalVar

Question
-
I am using MS Access 2013 and have used the Setlocalvar to execute a user defined public VBA function in a Data Macro in the past. When I go into the system and attempt it now I get an error "Microsoft Access can't parse the expression". I thought there may something wrong with my definition of the expression, so I copied one that is working and put it on a different table and I get the same error message. Also, when I go to the tables that have existing Data Macros with the SetLocalvar settings that execute vba code they all have the exclamation mark to the left. The ones that are setup are still functioning, I just can not create any new ones.
Has something changed that no longer allows a user created public function to be assigned to the SetLocalVar in a Data Macro? Or, is there a trick to get it to work that I have forgotten about?
Tuesday, March 13, 2018 8:43 PM
All replies
-
The function name isn't the same as a module name is it? Also, it should be specified as function name, including parenthesis even if no arguments and should not be preceded by the equal operator.
Paul ~~~~ Microsoft MVP (Visual Basic)
Tuesday, March 13, 2018 8:59 PM -
No, I copied one that works and it would not work either. i also created a simple function called Test that looked like this
Public function Test () as integer
Test=1
end function
It gave the same error message when I put Test() as the expression in the Data macro
Tuesday, March 13, 2018 9:03 PM -
No, I copied one that works and it would not work either. i also created a simple function called Test that looked like this
Public function Test () as integer
Test=1
end function
It gave the same error message when I put Test() as the expression in the Data macro
Hmm...seemed to work for me:
Do you have any bad (missing) References in your project?
Paul ~~~~ Microsoft MVP (Visual Basic)
Tuesday, March 13, 2018 10:34 PM -
Hi GBuzz,
I try to make a same test as Paul P Clement IV
I find that It is working on my side too.
I suggest you to create a new sample database for testing purpose and just try to create one function in it and try to call it from data macro to check whether it is working or not.
If that works successfully then you may again try to implement same in your original database and if issue persist then
you may try to compact and repair your database to correct any kind of corruption.
Let us know, Whether it solves your issue or not.
If not, Then we will try to provide further suggestions to solve the issue.
Regards
Deepak
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Wednesday, March 14, 2018 7:42 AM -
I found the problem I had to run the Compile command. When I ran the compile on the Module there was a function that had an error. Once that was corrected it allowed me to add functions to the setLocalvar
- Proposed as answer by Deepak Saradkumar PanchalMicrosoft contingent staff Thursday, March 15, 2018 8:33 AM
Wednesday, March 14, 2018 3:09 PM -
Hi GBuzz,
From your last post, I can see that your issue is solved now.
This thread is still open.
I suggest you to mark your own last post as an answer.
It will help us to close this thread and It will also be helpful for the community members in future who will have same kind of issue.
Thanks for your understanding.Regards
DeepakMSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Thursday, March 15, 2018 8:35 AM