Reputation: 2304
This line of code won't evaluate:
If(StrComp(Left("Campaign", 5), "IMS :") = 0
I'm using it like this:
strHolder = "If(StrComp(Left("Campaign", 5), "IMS :") = 0"
myVar = Application.Eval(strHolder)
This is the error I'm receiving:
Run-time error '2425': The expression you entered has a function name that Microsoft Access can't find.
I'm guessing that Application.Eval
can't read either the If
, StrComp
, or Left
Not sure what to do here, and I can't find the much in-depth info on the Eval
method.
Upvotes: 1
Views: 910
Reputation: 97131
This line of code won't evaluate:
If(StrComp(Left("Campaign", 5), "IMS :") = 0
And it wouldn't compile either due to unbalanced parentheses and If
without Then
.
There should also be a compile error at this line ...
strHolder = "If(StrComp(Left("Campaign", 5), "IMS :") = 0"
If you want something like this Immediate window example ...
? StrComp(Left("Campaign", 5), "IMS :") = 0
False
... then double up the "
characters within the string which you submit to Eval()
...
strHolder = "StrComp(Left(""Campaign"", 5), ""IMS :"") = 0"
? strHolder
StrComp(Left("Campaign", 5), "IMS :") = 0
myVar = Application.Eval(strHolder)
? myVar
0
? CBool(myVar)
False
Upvotes: 3