Form return value

  • Thread starter Thread starter Martin Dashper
  • Start date Start date
M

Martin Dashper

I want to open a modal dialog in such a way that it returns a value to
the calling code when it closes. Can this be done?

Martin Dashper
 
Is this a form or an actual dialog?

If a dialog you may be able to use the Filedialog (or similar object) if you
are using Access XP or later.

If this is a form, once it is closed, it will lose the value in any
variables. You could store the return value from the modal form in a global
variable, a custom property of the db, or in a variable on your switchboard
form (if you have one that remains open for the whole session of your
application). The next line of your calling code can then pick up the value.

If you want to make this a generic form you can drop into different
databases, I would say you should store the return value as a custom
property of the db. There is sample code in help that shows you how to test
if the custom property has been set up, and if it has not, how to create it
and then populate it. This way you can drop your form and calling code into
any db without having to do any further set up.
 
Martin said:
I want to open a modal dialog in such a way that it returns a value to
the calling code when it closes.


Another way to do that is to have the dialog form make
itself invisible instead of closing. this will also allow
the calling code to resume executions where it can retrieve
values from the form and close it:

DoCmd.OpenForm "dialogform", WindowMode:= acDialog
returnvalue = Forms!dialogform.sometextbox
DoCmd.Close acForm, "dialogform"
 
Back
Top