Problem with Eval function

Hello - I've been using the snip of code below in my application menus forever. "strExec" is the name of an Access object; when the user selects a menu option, it runs through the Select Case, doing the appropriate thing. If it's a user-defined function, it gets executed with the Eval() function in the Case Else.

Never had any problems up to now, but now I'm getting "The expression you entered contains invalid syntax." on this new UDF I just added. The only difference I can see is that this function contains arg's passed with "Optional ByVal"

This new function call works fine when exec'd from the Immediate Window.

It also works fine from my menu if I do not pass values for the "Optional ByVal" arg's:
     FormOpenStd("frmTest", "frmMainMenu")  <--- works
     FormOpenStd("frmTest", "frmMainMenu", , , , nvvarWndMode:=acWindowNormal, nvvarOpenArg:="CFrmID=frmMainMenu;Preset=0")modFrmSeriesProcs   <--- gets error



This is Access 2003

Any ideas?

Thanks

Select Case Left$(strExec, 3)
        Case "tbl"
            DoCmd.OpenTable strExec
        Case "qry"
            DoCmd.OpenQuery strExec
        Case "frm"
            Me.Visible = 0
            DoCmd.OpenForm strExec
        Case "rpt"
            DoCmd.OpenReport strExec, acViewPreview
        Case "mac"
            DoCmd.RunMacro strExec
        Case Else
            Eval (strExec)
    End Select

Open in new window

mlagrangeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tbsgadiCommented:
The new Udf has only 3 letters?
Can you post it
0
mlagrangeAuthor Commented:
The Select Case works off the 1st 3 char's of strExec, the Case Else uses the whole thing

And I left some junk on the end of the "gets error" example; sorry about that; that's not part of the call, obviously, it was in the Immediate Window
0
tbsgadiCommented:
It could be a problem with the quotation marks ""
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

mlagrangeAuthor Commented:
I call other other UDF's from this menu that have quotation marks; they work fine.

And this new UDF works fine, with the q's around the first 2 arg's, as long as I don't try to pass any of the Optional ByVal arg's
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Where is the Eval() function ?

mx
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
Instead of

     FormOpenStd("frmTest", "frmMainMenu", , , , nvvarWndMode:=acWindowNormal, nvvarOpenArg:="CFrmID=frmMainMenu;Preset=0")modFrmSeriesProcs   <--- gets error

What happens if you just pass the arguments without the :=  syntax.  Just pass the values.

?

mx
0
Rey Obrero (Capricorn1)Commented:
( Where is the Eval() function ? )

from VBA help type eval
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
LOL ... that's *not* what I was asking!  At first I didn't see it in the code, but I do now.  And the Q was 'Where', not 'What'!

mx
0
mlagrangeAuthor Commented:
>>> What happens if you just pass the arguments without the :=  syntax

Same error
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database ArchitectCommented:
The argument inside the Eval() function must evaluate to a String.  Put a break point on the Eval() ... and see if there is a proper String as an argument, ie ... no extra quotes, double quotes, etc.

mx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.