Annoying Hourglass problem!

wh00t

Registered User.
Local time
Today, 06:26
Joined
May 18, 2001
Messages
264
I have an annoying oddity with the hourglass and not sure why.

I run the following code and the hourglass does not display, I commented the DoCmd.Hourglass False to see if the hourglass did come on at all and it does but only after frmPrintOptions is open.
There are no hourglass statements on the report or form which are opened.

Any idea why the hourglass only shows after the code is run and is there a way round it?

Code:
DoCmd.Hourglass True
ResetCounter
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM tblList"
If DLookup("ReportOption", "tblOptions") Then
    DoCmd.OpenQuery "qryAppendTypeA"
Else
    DoCmd.OpenQuery "qryAppendTypeB"
End If
DoCmd.SetWarnings True
DoCmd.OpenReport "rptReport", acViewPreview
DoCmd.OpenForm "frmPrintOptions", acNormal
DoCmd.Hourglass False

btw, if your wondering if 'ResetCounter' has something to do with it, here's that code.
Code:
Option Explicit
Dim mlngCounter As Long

Function ResetCounter()
  mlngCounter = 0
End Function
 
why do you think this is not working - you are doing hardly anything after turning ther hourglass on -

unless these queries take a long while to run, you probably wont see the hourglass at all

doCmd.RunSQL "DELETE * FROM tblList"
If DLookup("ReportOption", "tblOptions") Then
DoCmd.OpenQuery "qryAppendTypeA"
Else
DoCmd.OpenQuery "qryAppendTypeB"
End If

... and as your code is not waiting for the form to close, the code drops through and turns the hourglass off again immediately
----------

how long do your queries take to run?
 
The queries are run over a very large recordset and do take a while to run which is why I require the hourglass.
 
in that case, the only other thing i can think of is that sometimes the screen does not refresh until some data gets written to it - so perhaps a me.repaint after the hourgalss command will force it to be displayed
 
Simple Software Solutions

What you need to do is to enter DoEvents after each step in your code this tells Access to process this part of the code before moving onto the next bit. You see, unlike Visual Basic, Access does not process one line at a time, what it attemps to do is to read all the lines of code into cache and then process it from there releasing the cashe as it progresses. By including the DoEvents forces Access to break up this code into segments. It is also good if you have a Cancel button to breakout of any code.

Another tip is to use the DoCmd.Echo command

Example:

DoCmd.Echo True, "Running Query, please wait...."

Places the above comment on the status bar.

CodeMaster::cool:
 
thats useful DC - i generally use doevents while im waiting for forms to close - i didnt realise it could/would force repaints etc
 
Simple Software Solutions

Gemma

Glad to be of help. You'd be surprised how many simple tips and tricks can be gleaned from reading others solutions.

David
:)
 
What you need to do is to enter DoEvents after each step in your code this tells Access to process this part of the code before moving onto the next bit. You see, unlike Visual Basic, Access does not process one line at a time, what it attemps to do is to read all the lines of code into cache and then process it from there releasing the cashe as it progresses. By including the DoEvents forces Access to break up this code into segments. It is also good if you have a Cancel button to breakout of any code.

Another tip is to use the DoCmd.Echo command

Example:

DoCmd.Echo True, "Running Query, please wait...."

Places the above comment on the status bar.

CodeMaster::cool:

Note:
Don't use DoEvents too often. It slow the application down significantly for the obvious reason: other processes get a change to do their thing.
 
Another Possibility

Hi Whoot,

I have had this problem myself in the past and it was caused by using non-standard Access buttons to carry out an event. For some reason using a picture, for example, instead of a button doesn't fire off the hourglass event in the same way that a standard button does, at least in the version of Access (XP) that I'm using.

I hope this helps.
 

Users who are viewing this thread

Back
Top Bottom