Modal forms returning values

S

Simon

I want to be able to offer the user the option to print,
preview, e-mail or export a report using a pop-up form
when the click report on a 'main' form. I know that if I
open a form using acDialog from the code on main, that
code will suspend until the user close the modal pop-up,
but what's the best way to pass their selection (i.e. if
they click 'e-mail') back to the main code to process?
 
R

Rick Brandt

Simon said:
I want to be able to offer the user the option to print,
preview, e-mail or export a report using a pop-up form
when the click report on a 'main' form. I know that if I
open a form using acDialog from the code on main, that
code will suspend until the user close the modal pop-up,
but what's the best way to pass their selection (i.e. if
they click 'e-mail') back to the main code to process?

What I usually do is offer an [OK] and a [Cancel] button on the popup.
[Cancel] closes the popup and [OK] just hides it (which also lets your
calling code continue). Then in the calling code I do something like...

(code uses the IsLoaded() function from the Northwind sample database)

DoCmd.OpenForm "MyPopup",,,,,acDialog

If IsLoaded("MyPopUp") = True
'User pressed [OK]
MyVariable = Forms!MyPopUp!SomeControl
DoCmd.Close acForm "MyPopUp"
Else
'User pressed [Cancel]
(do whatever)
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top