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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trap Eval

Status
Not open for further replies.

jibberski

Programmer
Aug 24, 2005
52
0
0
US
Is there a way to test the function Eval() for a valid return?

I'm receiving Error 2425: "The expression can't be found"

Code:
'With formula table
Do while not .EOF
  strAnswer = !formula
  For Each ctl In Me.Section(acDetail).Controls
    Do Until InStr(1, strAnswer, ctl.Tag) = 0
      strAnswer = Replace(strAnswer, ctl.Tag, ctl.value, 1, 1)
    Loop

[COLOR=red]If IsError(Eval(strAnswer)) = True Then[/color red]
   Call ScreenWrite
   'ScreenWrite will
   'parse formula for all Vars
   'get var properties 
   'ctl.tag = VarName
   'Unhide next control 
else
answer = Eval(strAnswer)
endif

Thanks for your time.
 
Why not use the errors?

Code:
On Error GoTo TrapErr

<...>

TrapErr:
Select Case Err.Number
    Case 2425
        MsgBox "Problem"
    Case Else
        Debug.Print Err.Description
End Select
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top