Chapter 13 - Forms as objects
I am trying to use this code , and I cannot get the code in the calling form to wait for the dialog form to return the values so I can use them. It immediately runs all the code, does the Case Else statement and only then switches to the dialog form. I set the dialog form as modal, but that does not help.
Here is the calling code:
This is in the declaration section
Option Compare Database
Option Explicit
Private WithEvents dlg As Form_dlgMyDialog
Public VarReturn1 As Variant
Public VarReturn2 As Variant
Private Sub dlg_finished(VarReturn1 As Variant, VarReturn2 As Variant)
VarReturn1 = VarReturn1
VarReturn2 = VarReturn2
End Sub
This is in the command button:
Private Sub cmdselect_click()
Set dlg = New Form_dlgMyDialog
dlg.Visible = True
Select Case varReturn1
Case 1
DoCmd.OpenReport stDocName, acPreview, , "Not tblMiscDetails.txtMechanech='ú'"
Case 2
DoCmd.OpenReport stDocName, acPreview, , "tblMiscDetails.txtMechanech= 'ú'"
Case 3
DoCmd.OpenReport stDocName, acPreview
Case Else
MsgBox "Wrong Choice"
End Select
Thanks
Zave
|