Tom,
I looked into the Eval function but either I don't understand enough
about how to use it or it's not going to do what I need it to. I'm
attempting to create a function call like
Forms("MyForm").MyFunction #4/12/2004#
which will call a sub-routine in another form and pass it a date
value. The problem is that the Eval function keeps reporting a syntax
error. I try to pass in the form name and function name into the
calling form through the OpenArgs parameter, parse them out, and call
the function from that form.
The calling form contains the following code:
DoCmd.OpenForm "frmCaller", OpenArgs:=Me.Name & ";MyCallback"
The form that invokes the callback function (frmCaller) does the
following with the data in the OpenArgs variable
Dim args As String
Dim sepIdx As Integer
Dim formName, callback As String
args = Me.OpenArgs 'contains the form name and function name to call
sepIdx = InStr(args, ";")
formName = Mid(args, 1, sepIdx - 1) 'parse out form name
callback = Mid(args, sepIdx + 1, Len(args) - sepIdx) 'parse out
callback
Eval "Forms(""" & formName & """)." & callback & " #1/1/2004#"
I get a message box saying "The expression you entered contains
invalid syntax". I was looking at the documentation on the Eval
function and it seemed to indicate that the routine called should
return a value. So I made the callback routine return a meaningless
value. Executing that code just caused Access to crash. The callback
function sets the value of a certain control in another form. Could
that be the problem? I'm stumped.
Dave
Tom van Stiphout <to*****@no.spam.cox.net> wrote in message news:<lc********************************@4ax.com>. ..
On 10 Apr 2004 14:38:46 -0700, he******@aol.com (headware) wrote:
Check out Eval in the help file.
-Tom.
I know that you can call the method of one from from inside another
form by doing something like this
Forms("MyForm").MyFunction(12, 34)
However, you have to know that MyForm has a function called
MyFunction. Can you specify a string for the function name like you
can with the form name? That is can I do something like
Forms("MyForm")."MyFunction"
and still supply some arguments to the funciton somehow?
Thanks,
Dave