How do I make the program to wait?

  • Thread starter Thread starter G Lam
  • Start date Start date
G

G Lam

Hi,
I wrote some VBA codes in a main form's (PackForm) AfterUpdate event to open
a Popup form. I set the popup form to Modal = yes, popup = yes. I had a OK
button in the popup form. What I want it to do is, once the pop form opens,
the user is able to chose a record and set a field value from that record to
the PackForm.
I think, after the Popup form opens, the AfterUpdate event should stop and
wait for the user to click the OK button and then the control goes back to
the AfterUpdate event. But that is not the case. The AfterUpdate event keeps
on going and does not wait for the user to click OK after the Popup form
opens. How can I change this behavior?
Thank you,
Gary
 
Create a public procedure to open a form and then wait for the form to be
closed before returning.

Public Sub Open_Form(MyFormName As String)
On Error GoTo Error_Open_Form

Dim frm As Form

DoCmd.OpenForm MyFormName, acNormal

For Each frm In Forms
If frm.Name = MyFormName Then
While frm.Visible
DoEvents
Wend

Exit For
End If
Next frm

Error_Open_Form:

End Sub
 
Hello
Here's how to (acDialog - Parameter) doing this
without Permanent While

Private Sub cmdPopUp_Click()
MsgBox "Hello"
DoCmd.OpenForm "PopUpForm", acNormal, , , , acDialog
MsgBox "Now it should have been waited"
End Sub

Heiko
:-)
 
Back
Top