Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Evaluating expression stored in string variable

Status
Not open for further replies.

alang777

Programmer
May 17, 2006
2
US
How can Access/VBA evaluate a variable containing an expression string as an expression rather than as a string?

E.g.,
Code:
varExpr = "1 + 1"

How do I evaluate the contents of varExpr to get 2 instead of "1 + 1"?

Dlookup() requires a domain, and Access has no equivalent of Excel's Indirect()... Also, I've tried ByVal versus ByRef but it doesn't help. I need something like RunExpression(strExpr) if it exists!!

The bigger context is constructing SQL strings with "parameter" variables or tokens where the parameter tokens are replaced by the value of my own functions such as CurrentFiscalMonth() (e.g, "200709") or ThisMonday() (e.g., #9/17/2007#).

Thanks in advance for any hints :)
 
Have a look at Eval

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

That's it!!

I've needed Eval() before but never knew the trick!

Thanks MajP! A blessing upon you and your family!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top