Anyone can help me on this?
I am running Access 2000 and trying to use the Eval function to pass a string and have it execute what the string evauates to. It seems when I pass it multiple parameters within that string it doesn't work. I have 2 code snippets below to show what I mean.
Ideas anyone? Need more info, let me know.
Thanks, Mark
'====Snip 1====
Private Sub Command0_Click()
Eval ("MsgBox(""msg""
"
'Works passing single parameter
' string evaluates to: MsgBox("msg"
Eval ("MsgBox(""msg"", , ""title""
"
' Doesn't work, multiple parameters-- error 2431
' string evaluates to: MsgBox("msg", , "title"
End Sub
'===Snip2===
Private Sub Command0_Click()
Dim x As String
x = "DoCmd.OpenReport (""R1""
"
Debug.Print x
Eval (x)
' Works – single parameter
x = "DoCmd.OpenReport (""R1"", 2)" ' acPreview = 2
Debug.Print x
Eval (x)
'Not work
End Sub
I am running Access 2000 and trying to use the Eval function to pass a string and have it execute what the string evauates to. It seems when I pass it multiple parameters within that string it doesn't work. I have 2 code snippets below to show what I mean.
Ideas anyone? Need more info, let me know.
Thanks, Mark
'====Snip 1====
Private Sub Command0_Click()
Eval ("MsgBox(""msg""
'Works passing single parameter
' string evaluates to: MsgBox("msg"
Eval ("MsgBox(""msg"", , ""title""
' Doesn't work, multiple parameters-- error 2431
' string evaluates to: MsgBox("msg", , "title"
End Sub
'===Snip2===
Private Sub Command0_Click()
Dim x As String
x = "DoCmd.OpenReport (""R1""
Debug.Print x
Eval (x)
' Works – single parameter
x = "DoCmd.OpenReport (""R1"", 2)" ' acPreview = 2
Debug.Print x
Eval (x)
'Not work
End Sub