Dynamic If...Then using variables

mmitchell

Registered User.
Local time
Today, 11:40
Joined
Jan 7, 2003
Messages
80
I am trying to make a "dynamic" If...then statement in VBA to evaluate something like: "If -1 >= 0 Then"

I have a table that contains a field that contains a string like: ">14"

So I do a Dlookup to get that value (vYellow varient) and I want to use it in an If...then like this:

If Eval(strInspType & " " & Eval(vYellow)) Then
MakeColorTransfomer = "Y" 'Yellow
End If

Where strInspType is a number beging past as a string.

When I run it I get this error: "The expression you entered contains invalid syntax"
When strInspType is "-1" and vYellow is "=0"

What I am attempting to do is evaluate a value (strInspType) against whatever the dlookup returns, it will ether be > or < or = to a number. strInspType is being based as a string because the field in the table does not always contain numbers, sometimes words like "none" etc. But if it is a number then I need to compair it with whatever I find in the Dlookup.
 
You may be able to to use some thing like a left() to grab the > and test off that.

Ken
 
This seemed to do the trick for me.

If Eval(strInspType & " " & vYellow) Then

I took out the second eval.
 

Users who are viewing this thread

Back
Top Bottom