Implementing popup form

D

Dorian

I have a form which I need to popup, collect data from a textbox, then
disappear returning the data to my calling form. I have it all working but
the popup form does not disappear when it is unloaded even when I have
Me.visible = false in the unload event and in the button event which closes
the form. The form is defined as popup=yes, modal=yes. I open the form in
dialog mode to retrieve the data in my application, the form is made
invisible and then closed in the calling form.
Any idea how to make it reliably become invisible before it returns control
to my other form? Access 2003. Here is the code:

Popup form:

Private Function GetUpdateMsg() As String
On Error GoTo ER
DoCmd.OpenForm "frmTicketUpdate", , , , , acDialog
GetUpdateMsg = [Forms]![frmTicketUpdate].[UpdMsg]
DoCmd.Close acForm, "frmTicketUpdate"
Exit Function
ER:
On Error Resume Next
DoCmd.Close acForm, "frmTicketUpdate"
MsgBox Err.Description, , "GetUpdateMsg"
GetUpdateMsg = vbNullString
End Function

Private Sub Form_Load()
Me!UpdMsg = vbNullString
Me!UpdMsg.SetFocus
End Sub

Private Sub butOK_Click()
Me!UpdMsg = Trim(Me!UpdMsg)
Me.Visible = False
Me.Repaint
End Sub

Private Sub butCancel_Click()
Me!UpdMsg = vbNullString
Me.Visible = False
Me.Repaint
End Sub

Private Sub Form_Unload(Cancel As Integer)
Me.Visible = False
Me.Repaint
End Sub

Calling form:
 
D

Dale Fye

Dorian,

I would take the me.Repaint lines out of OK_Click and Cancel_Click code, but
otherwise, it looks very similar to what I usually do, and I've never
encountered a situation where the form failed to hide properly.

Sorry I cannot be more help.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
D

Dorian

Deleting the Repaint statements did not help.
What is happening is that after this data is collected, I go back to the
procedure which called the popup. This procedure is composing an Outlook
email and I am getting the Microsoft security prompt while the popup form is
still present. This is well after the form has been made invisible.
Maybe this is a timing issue and I need to insert a delay loop?


Dale Fye said:
Dorian,

I would take the me.Repaint lines out of OK_Click and Cancel_Click code, but
otherwise, it looks very similar to what I usually do, and I've never
encountered a situation where the form failed to hide properly.

Sorry I cannot be more help.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Dorian said:
I have a form which I need to popup, collect data from a textbox, then
disappear returning the data to my calling form. I have it all working but
the popup form does not disappear when it is unloaded even when I have
Me.visible = false in the unload event and in the button event which closes
the form. The form is defined as popup=yes, modal=yes. I open the form in
dialog mode to retrieve the data in my application, the form is made
invisible and then closed in the calling form.
Any idea how to make it reliably become invisible before it returns control
to my other form? Access 2003. Here is the code:

Popup form:

Private Function GetUpdateMsg() As String
On Error GoTo ER
DoCmd.OpenForm "frmTicketUpdate", , , , , acDialog
GetUpdateMsg = [Forms]![frmTicketUpdate].[UpdMsg]
DoCmd.Close acForm, "frmTicketUpdate"
Exit Function
ER:
On Error Resume Next
DoCmd.Close acForm, "frmTicketUpdate"
MsgBox Err.Description, , "GetUpdateMsg"
GetUpdateMsg = vbNullString
End Function

Private Sub Form_Load()
Me!UpdMsg = vbNullString
Me!UpdMsg.SetFocus
End Sub

Private Sub butOK_Click()
Me!UpdMsg = Trim(Me!UpdMsg)
Me.Visible = False
Me.Repaint
End Sub

Private Sub butCancel_Click()
Me!UpdMsg = vbNullString
Me.Visible = False
Me.Repaint
End Sub

Private Sub Form_Unload(Cancel As Integer)
Me.Visible = False
Me.Repaint
End Sub

Calling form:
 
D

Dorian

Inserting a 1/2 second delay after the docmd.close for the form solved the
problem.
I guess it takes a few milliseconds after the form is closed to actualy
remove the form.

DoCmd.OpenForm "frmTicketUpdate", , , , , acDialog
GetUpdateMsg = [Forms]![frmTicketUpdate].[UpdMsg]
DoCmd.Close acForm, "frmTicketUpdate"
<-- I inserted 1/2 second delay here -->
Exit Function

-Dorian

Dorian said:
Deleting the Repaint statements did not help.
What is happening is that after this data is collected, I go back to the
procedure which called the popup. This procedure is composing an Outlook
email and I am getting the Microsoft security prompt while the popup form is
still present. This is well after the form has been made invisible.
Maybe this is a timing issue and I need to insert a delay loop?


Dale Fye said:
Dorian,

I would take the me.Repaint lines out of OK_Click and Cancel_Click code, but
otherwise, it looks very similar to what I usually do, and I've never
encountered a situation where the form failed to hide properly.

Sorry I cannot be more help.
--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



Dorian said:
I have a form which I need to popup, collect data from a textbox, then
disappear returning the data to my calling form. I have it all working but
the popup form does not disappear when it is unloaded even when I have
Me.visible = false in the unload event and in the button event which closes
the form. The form is defined as popup=yes, modal=yes. I open the form in
dialog mode to retrieve the data in my application, the form is made
invisible and then closed in the calling form.
Any idea how to make it reliably become invisible before it returns control
to my other form? Access 2003. Here is the code:

Popup form:

Private Function GetUpdateMsg() As String
On Error GoTo ER
DoCmd.OpenForm "frmTicketUpdate", , , , , acDialog
GetUpdateMsg = [Forms]![frmTicketUpdate].[UpdMsg]
DoCmd.Close acForm, "frmTicketUpdate"
Exit Function
ER:
On Error Resume Next
DoCmd.Close acForm, "frmTicketUpdate"
MsgBox Err.Description, , "GetUpdateMsg"
GetUpdateMsg = vbNullString
End Function

Private Sub Form_Load()
Me!UpdMsg = vbNullString
Me!UpdMsg.SetFocus
End Sub

Private Sub butOK_Click()
Me!UpdMsg = Trim(Me!UpdMsg)
Me.Visible = False
Me.Repaint
End Sub

Private Sub butCancel_Click()
Me!UpdMsg = vbNullString
Me.Visible = False
Me.Repaint
End Sub

Private Sub Form_Unload(Cancel As Integer)
Me.Visible = False
Me.Repaint
End Sub

Calling form:
 

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