Microsoft Access
--
Questions
--
Followers
Top Experts
Formula based off field - MS Access
Hi Experts!
I'm wondering if there is a way in which I could take a series of variables and allow users to construct custom forumlas off those to run calculations.
So for example, I may have 4 variables -- Â A, B, C, D. Â Would there be a way I could do an 'expression builder' where I could -say- let users build a formula such as "Â A + B ^ 0.5 "Â and then use that formula elsewhere to display data?
Maybe a sub form that allows logic to be built and then on save VB updates the variable?
I'm wondering if there is a way in which I could take a series of variables and allow users to construct custom forumlas off those to run calculations.
So for example, I may have 4 variables -- Â A, B, C, D. Â Would there be a way I could do an 'expression builder' where I could -say- let users build a formula such as "Â A + B ^ 0.5 "Â and then use that formula elsewhere to display data?
Maybe a sub form that allows logic to be built and then on save VB updates the variable?
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
ASKER CERTIFIED SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
No points, please.
As Gustav said, the Eval() function will do the job.
You could have your users enter the function in a text box, like:
A + B ^ .05
Then you could use the Replace() function to replace instances of each of the variables:
strEval = Replace(me.txt_Eval, "A", "Str(A)")
strEval = Replece(strEval, "B", "Str(B)")
...
Then you could store that value and use it Elsewhere in your code.
As Gustav said, the Eval() function will do the job.
You could have your users enter the function in a text box, like:
A + B ^ .05
Then you could use the Replace() function to replace instances of each of the variables:
strEval = Replace(me.txt_Eval, "A", "Str(A)")
strEval = Replece(strEval, "B", "Str(B)")
...
Then you could store that value and use it Elsewhere in your code.
Ah, great thanks to both!
You are welcome!
/gustav
/gustav






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Microsoft Access
--
Questions
--
Followers
Top Experts
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.