SimonKravis
asked on
Cannot set Hourglass cursor during Access Form refresh
I am trying to set the hourglass icon in an Access 2003 form while it runs a long query with a new recordsource with the code snippet below. The icon remains as an arrow all the time the code executes. If I set a breakpoint at line 250, the hourglass icon appears after I continue execution from that point and disappears after executing line 350.
240 lblStatus.Caption = "Executing Regexp filter.."
250 Screen.MousePointer = 11 ' set to hourglass
260 DoEvents
....
270 Me.RecordSource = vSource(0) & " where " & sFilter & " and " & vSource(1)
340 Form.Refresh
345 lblStatus.Caption = ""
350 Screen.MousePointer = 0 ' return to arrow
ASKER
Same results - the hourglass icon does not appear unless set a breakpoint in the code after the hourglass icon has been set
Looking at the code, I bet the pointer changes to hourglass and then back again too fast for you to see it. Try remarking out the line
350 Screen.MousePointer = 0 ' return to arrow
350 Screen.MousePointer = 0 ' return to arrow
BTW:
Form.Refresh
is not needed. The form requeries whenever the record source is changed,
Form.Refresh
is not needed. The form requeries whenever the record source is changed,
ASKER
Thanks for the tip about the redundant Refresh. The query takes about 15 seconds to run, based on changes to lblStatus so it isn't a case of the hourglass appearing momentarily. The puzzle is why it appears if I set a breakpoint in the code.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The lblStatus label control doesn't have it's value cleared ( line 340 ) until 15 seconds after the Recordsource setting, so I don't think that execution is asynchronous. Also, when single stepping using F8 from a breakpoint set at line 270, there is a long pause before line 370 is highlighted.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
to get the labgel to display you could use the following
330 lblStatus.Caption = "Setting Caption.."
335 lblStatus.Refresh
Will also cause the label to refresh. with out the need for the DoEvents. and this should also remove the need for the msgbox
330 lblStatus.Caption = "Setting Caption.."
335 lblStatus.Refresh
Will also cause the label to refresh. with out the need for the DoEvents. and this should also remove the need for the msgbox
DoCmd.Hourglass True
and of course to set it back:
DoCmd.Hourglass False