Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clicking on a pop-up form freezes an application, why?

Status
Not open for further replies.

sudakov

Programmer
Jun 17, 2007
53
US
Hi everyone,

I have a pop-up form (POP UP property set to YES) that displays a WAIT message, while my code performs activity that takes some time (compacting, copying files etc). At the end of the code I close this pop-up form programmatically.

Everything works fine until a user decides to click on that pop-up form (for a reason to close it or without any reason). My application stops to respond. It looks to me it couldn't exit from the activity it did before the user clicked on the pop-up form.

Does anyone have idea how to get around this problem?

Your help is appreciated.

sudakov
 
sudakov.
here's my solution

my msgForm contains
- lbl to display 'ready'
- ok btn
- lbl to display a message
- time labels to display start/stop time

'msg form code frmMsgBox

Private Sub cbOK_Click()
DoCmd.Close , , acSaveNo
End Sub

Private Sub Form_Open(Cancel As Integer)
If Not IsNull(Me.OpenArgs) Then Msg.Caption = Me.OpenArgs
txtStart = Now()
End Sub

'---------------------------
'calling code from anywhere in your program

Sub putMsg(strMsg As String) 'Display Modal message form - or send text to it
If Not IsLoaded("frmMsgBox") Then
DoCmd.OpenForm "frmMsgBox", , , , , , strMsg 'if not open, open it with message
Else
Forms![frmMsgBox]!Msg.Caption = strMsg 'otherwise: change message on it
End If
Forms![frmMsgBox].Repaint

End Sub


'------------------------------------------------
'termination code from anywhere in your program
in dutch:
klaar = ready
einde = end
duur = duration

when you use stopmsg(false) the box disappears and the program contunue's
in some instances you will need DoEvents in your program

Sub StopMsg(blnVis As Boolean)
If IsLoaded("frmMsgBox") Then
Forms![frmMsgBox]!lblKlaar.Visible = True
Forms![frmMsgBox]!txtEinde = Now()
Forms![frmMsgBox]!txtDuur = _
Format(CDate(Forms![frmMsgBox]!txtEinde) - _
CDate(Forms![frmMsgBox]!txtStart), "Hh:Nn:Ss")

Forms![frmMsgBox]!txtEinde.Visible = True
Forms![frmMsgBox]!lblEinde.Visible = True
Forms![frmMsgBox]!txtDuur.Visible = True
Forms![frmMsgBox]!lblDuur.Visible = True

If blnVis Then
'ZetMsg "Klaar."
Forms![frmMsgBox]!cbOK.Visible = True
Else
DoCmd.Close acForm, "frmMsgBox", acSaveNo
End If
End If
End Sub


'helper function to det. if a form is open
Function IsLoaded(ByVal strFormname As String) As Integer
' Levert Waar op als het opgegeven formulier is geopend
' in formulier- of gegevensbladweergave.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormname) <> conObjStateClosed Then
If Forms(strFormname).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function
 
Hi Huub0,

thank you for your solution.

Your solution actually looks very similar to what I have, with one small difference - my message-form is not Modal, so it allows a user to reply to messages generated by the application, but it is Popup, so it stays on the top of other open forms.

Did you try to drag your message-form while your software performs some activities?

Sudakov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top