Screen freezes

N

Niels Verkaart

Hi ,

In our application there are many processes that take more than 5 seconds to
complete (eg imports and exports). In these cases we present users with
status screens like showing text what is going on or a progressbar.

After 5-10 seconds these screens freeze while the program is still doing
it's work and sets the properties for the status screens (or at least it
tries to do that). When the process finishes the screen is at last updated
to the last status text action, but doesn't close.

This behaviour is reported from the beginning of this project. Also, when we
ctrl-break into the code and continue processing, it does work all the way.
Does anyone know of this behaviour and maybe have a solution?

Niels Verkaart
 
S

Stefan Hoffmann

hi,

Niels said:
After 5-10 seconds these screens freeze while the program is still doing
it's work and sets the properties for the status screens (or at least it
tries to do that). When the process finishes the screen is at last updated
to the last status text action, but doesn't close.
Do you use Form.Repaint after setting the status screen properties?

mfG
--> stefan <--
 
N

Niels Verkaart

Yes, this is our code:

Sub ShowStatus(Message As String, Optional Caption As String = cCaption)
' v1.01 29/6/01

On Error GoTo procErr

procAgain:
If GetMessageOutputType() = motScreen Then
With frmStatus
If Not .Visible Then
DoCmd.Hourglass True
.Visible = True
End If
.MessageText.Caption = Message
.Caption = Caption
.Repaint
End With
Else
'12/1/06
WriteMessage Message, brmStatus, 1
End If

procExit:
Exit Sub

procErr:
If err.Number = 91 Or err.Number = 2467 Then
Set frmStatus = New Form_sysfrmStatus
Resume procAgain
Else
ShowErr err
Resume procExit
End If

End Sub
 
S

Stefan Hoffmann

hi Niels,

Niels said:
Yes, this is our code:

Sub ShowStatus(Message As String, Optional Caption As String = cCaption)
' v1.01 29/6/01

On Error GoTo procErr

procAgain:
If GetMessageOutputType() = motScreen Then
With frmStatus
If Not .Visible Then
DoCmd.Hourglass True
.Visible = True
End If
.MessageText.Caption = Message
.Caption = Caption
.Repaint
Try also a DoEvents here.

This one does it for me:

Public Sub ShowStatus(AMessage As String)

If FormIsLoaded("Status") Then
DoCmd.Hourglass (AMessage <> "")
Forms("Status").Form.lblStatus.Visible = (AMessage <> "")
Forms("Status").Form.lblStatus.Caption = AMessage
Forms("Status").Form.Repaint
End If

End Sub


mfG
--> stefan <--
 
N

Niels Verkaart

Hello Stefan,

do you think it might have something to do with the public form variable?
And that i should change it in a normally opened form?

PS: It might get slower though by using our big Name space of our forms
(approx 250+)

thanks,
Niels
 
S

Stefan Hoffmann

hi Niesl,

Niels said:
do you think it might have something to do with the public form variable?
And that i should change it in a normally opened form?
Maybe that value is lost.
PS: It might get slower though by using our big Name space of our forms
(approx 250+)
Try the following:

Dim frmStatus As Access.Form

If Not FormIsLoaded("Status") Then
DoCmd.OpenForm "Status")
End If

DoCmd.Hourglass (AMessage <> "")
frmStatus = Forms("Status").Form
frmStatus.lblStatus.Visible = (AMessage <> "")
frmStatus.lblStatus.Caption = AMessage
frmStatus.Repaint

Drop the With in your funciton, in some cases this can cause problems.


mfG
--> stefan <--
 
N

Niels Verkaart

oke Stefan, i'll try.

how about that 'with' problem? Is there any reference to it, because i
didn't know and i use it a lot.

cheers,
Niels
 
S

Stefan Hoffmann

hi Niels,

Niels said:
how about that 'with' problem? Is there any reference to it, because i
didn't know and i use it a lot.
When it causes trouble, it is always that the With works with an invalid
pointer (kind of). The most common problem here is using it with an
OLE-Server:

Dim obj As Excel.Application
Set obj = New Excel.Application
With obj
'**
End With

If it remains a longer time in the With, it may loose contact to the
Ole-Server. This can happen even if the server is still running.

Your special error handling just made me suspicious.

mfG
--> stefan <--
 
T

Terry Kreft

Try
.MessageText.Caption = Message
.Caption = Caption
.Repaint
DoEvents
End With
 

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