Full Version: Cannot get the Hourglass to display
UtterAccess Forums > Microsoft® Access > Access Forms
Speedy
Hi everyone,
quick question on using the HOURGLASS mousepointer.
I have a form that takes about 5 seconds to load. The form loads from a command button click. I want the mouse pointer to change to an hourglass while the form is loading, and then go back to normal after the form has loaded.
The code I have in the Click event on the main menu is:
'Set the cursor to hourglass
Application.Screen.MousePointer = 11

'Open the reports form
DoCmd.OpenForm "frmReports"
and on the Activate event of the reports form I have
'Set the cursor to normal
Application.Screen.MousePointer = 0
I find that the mouse pointer does not change at all. If I remove the Activate event, so the mousepointer doesnt change back to 0 I find that the hourglass does not come on until after all the code stops running. Even though I have my mousepointer=11 code before the OpenForm line, the hourglass stays as an arrow until after the new form has loaded and all code execution has finished.
I've tried several things like a DoEvents and screen repaints between the "Application.Screen.MousePointer = 11" line and the OpenForm line but nothing seems to work.
Does anyone have any ideas?
Thanks,
Jon
R. Hicks
Try using ...
oCmd.Hourglass True
and
DoCmd.Hourglass False
RDH
Speedy
Ricky,
Thanks for the quick reply.
Yeah, I tried this first as I found the doCmd.Hourglass entries in Help while researching this. This method has the same effect. It seems that nothing refreshes until after the code has finished running or at least breaks. For example, I tried this to see what happens:
'Set the cursor to hourglass
doCmd.Hourglass True
Msgbox "Boo"
'Open the reports form
DoCmd.OpenForm "frmReports"
...and my cursor turns to an hourglass when the msgbox displays. It returns to an arrow when the new form has finished loading. I then remove the Msgbox statement and click the command button and the hourglass does not appear.
--Jon
R. Hicks
Not sure I follow you ...
If you want the hourglass to appear befpre the form opens .. use:
CODE
DoCmd.Hourglass True

'Open the reports form
DoCmd.OpenForm "frmReports"

Then in the On Open event of this form use:
CODE
Private Sub Form_Open(Cancel As Integer)
DoCmd.Hourglass False
End Sub

The above will turn the hourglass off ...
RDH
Speedy
Hi Ricky,
hat's exactly the code I have.
The hourglass doesnt come on though. It seems that access doesnt display the hourglass immediately when the "DoCmd.Hourglass True" is executed. I think the setting for the hourglass is being changed but the cursor doesnt actually change until after the VBA code stops running.
To prove this, I remove the "DoCmd.Hourglass False" code in the new forms OPEN event. When I click the button the cursor stays as an arrow for the 5 seconds or so while new form load, and then once the form loads and control returns to the user the hourglass will come on.
I'm wondering if there's some kind of refresh or repaint function I can use immediately after the "DoCmd.Hourglass True" statement to make the hourglass display immediately.
Thanks,
Jon
R. Hicks
In your code put:
oCmd.Hourglass True
DoEvents
See if that helps ...
RDH
Speedy
LOL...Yepp, tried that.... I'm stumping you, eh.
also tried a "me.repaint" Nothing helps.
I wanted to see if the problem was due to my form taking so long to load so I put in a FOR/NEXT loop within the first form.
I put this in the Click event on a button on my main menu:
dim c as long
DoCmd.Hourglass True
for c = 1 to 40000
doevents
next c
Exit sub
When I click the command button, the code runs for a minute or so with the cursor staying an arrow. When the loop finishes and control returns to the form, the cursor changes to an hourglass.
I would have thought that the Hourglass would come on immediately but it doesnt. It definately only comes on when code execution finishes.
--Jon
R. Hicks
Not so much stumping me .. as I do not have the app to see exactly what you have going on ....
Oonly see part of the picture ...
Can you compact and zip up the offending app and attach it to a reply so I can see what is going on ???
RDH
Speedy
Thanks Ricky. I've tried attaching a ZIP file but I get the message "Cannot Proceed. Use your browser back button to return to the message." <y dialup may be too slow for the forum software and it's timing out... ....anyways....
I have been running this Hourglass function from the CLICK event of a label control. I have found that when I run the events from a COMMAND BUTTON click, the hourglass function works fine. It just doesnt work when run from the CLICK event of a label.
Omay have to change all my labels to command buttons, but I like the way they look as labels much better than command buttons.
Anyway, thanks for taking the time to help out a beginner like me. Can you think of why I would get problems running from a click event of a label control?
Cheers,
Jon
R. Hicks
Without a copy of the app so I can see what is going on .. anything I post whot be only a guess ...
DH
dannyseager
Jon, The zip file must be under 500KB
schroep
Jon -
See this thread:
http://www.utteraccess.com/forums/showflat...?Number=1085810
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.