Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Implementing popup form

Geek News

Implementing popup form
Dorian 12/8/2008 3:18:11 PM
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:
RE: Implementing popup form
Dale Fye 12/8/2008 4:21:03 PM
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" wrote:

[Quoted Text]
> 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:
RE: Implementing popup form
Dorian 12/8/2008 4:55:02 PM
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" wrote:

[Quoted Text]
> 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" wrote:
>
> > 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:
RE: Implementing popup form
Dorian 12/8/2008 5:14:01 PM
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" wrote:

[Quoted Text]
> 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" wrote:
>
> > 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" wrote:
> >
> > > 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:

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net