Communicating With Dialog Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

When a dialog form is opened, execution of the calling code is interrupted
until the dialog form is made invisible. What do I do if I want to open a
dialog form, but set certain controls to have default values, which are
specific to the code which is calling the form?

I see two ways of doing this:
1) Set the properties before the form is opened. But are any objects
provided for accessing forms that aren’t open?
2) Set the properties after the form is opened. But execution of the calling
code has stopped…

Any help with this would be most gratefully received!

Many thanks

David
 
David said:
Hi all

When a dialog form is opened, execution of the calling code is
interrupted until the dialog form is made invisible. What do I do if
I want to open a dialog form, but set certain controls to have
default values, which are specific to the code which is calling the
form?

I see two ways of doing this:
1) Set the properties before the form is opened. But are any objects
provided for accessing forms that aren't open?
2) Set the properties after the form is opened. But execution of the
calling code has stopped.

Options...

Public variables

Set value of hidden controls on calling form and then called form can retreive
them

Pass them in the OpenArgs to the called form.
 
Hi Rickin

Thank you for this. The obvious ideal thing to do here would be to supply a
couple of lines of code in a string as the OpenArgs argument, which would
then be executed by the called form when the Open Event is triggered.

Is there a function which accepts a string as an argument, and then just
executes it as code, for example:

Dim MyCode As String
MyCode = "MsgBox " & chr(34) & Hello World & chr(34)"
ExecuteCode(MyCode)

Thanks again

David
 
Thank you for this. The obvious ideal thing to do here would be to supply
a
couple of lines of code in a string as the OpenArgs argument, which would
then be executed by the called form when the Open Event is triggered.

No, but you are wanting to pass a bunch of values. Why not use:


docmd.OpenForm "MyForm",,,,,,"parm1~parm2~parm3"

In other words, just pass as many parms as a delimited string.

In the forms on-load event, you can go:


msgbox "parm 1 is = " & split(me.openargs,"~")(0)

msgbox "parm 2 is = " & split(me.openargs,"~")(2)

Or, if you must...pull the parmaters into a array

dim v as varient

v = split(me.openargs,"~")

msgbox "parm 1 is = " & v(0)

msgbox "parm 2 is = " & v(1)
 
Back
Top