Annoying Hourglass problem! (1 Viewer)

wh00t

Registered User.
Local time
Today, 08:32
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
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:32
Joined
Sep 12, 2006
Messages
15,730
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?
 

wh00t

Registered User.
Local time
Today, 08:32
Joined
May 18, 2001
Messages
264
The queries are run over a very large recordset and do take a while to run which is why I require the hourglass.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:32
Joined
Sep 12, 2006
Messages
15,730
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
 

DCrake

Remembered
Local time
Today, 08:32
Joined
Jun 8, 2005
Messages
8,626
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:
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:32
Joined
Sep 12, 2006
Messages
15,730
thats useful DC - i generally use doevents while im waiting for forms to close - i didnt realise it could/would force repaints etc
 

DCrake

Remembered
Local time
Today, 08:32
Joined
Jun 8, 2005
Messages
8,626
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
:)
 

Guus2005

AWF VIP
Local time
Today, 09:32
Joined
Jun 26, 2007
Messages
2,642
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.
 

StuartF

New member
Local time
Today, 08:32
Joined
May 23, 2008
Messages
1
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

Top Bottom