Modal forms returning values

  • Thread starter Thread starter Simon
  • Start date Start date
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?
 
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
 
Back
Top