Hourglass visible command button vs label

L

Lauren Quantrell

Using Access2000, I've finally figured out that if you pass the exact
same function from the OnClick event of a label or a command button,
the Hourglass will never appear if the function is executed from the
label but it will appear when executed from the command button.
Does anyone know a way around this without having to overlay invisible
command buttons on top of every label?
Any help is appreciated.
lq

For example
myLabel.OnClick = "=myFunctionName()"
myCommandButton.OnClick = "=myFunctionName()"


Function myFunctionName()

' Hourglass never appears for OnClick from a label
' but does from a command button

DoCmd.Hourglass true

'execute whatever code

DoCmd.Hourglass false

End Function
 
D

Dirk Goldgar

Lauren Quantrell said:
Using Access2000, I've finally figured out that if you pass the exact
same function from the OnClick event of a label or a command button,
the Hourglass will never appear if the function is executed from the
label but it will appear when executed from the command button.
Does anyone know a way around this without having to overlay invisible
command buttons on top of every label?
Any help is appreciated.

That's an interesting quirk. You can get around it by making a call to
the Windows API to set the cursor yourself. Paste this code (from The
Access Web site, code written by Terry Kreft) into a standard module:

'----- start of code for module basMouseCursor -----
'Code Courtesy of
'Terry Kreft
'
Public Const IDC_APPSTARTING = 32650&
Public Const IDC_HAND = 32649&
Public Const IDC_ARROW = 32512&
Public Const IDC_CROSS = 32515&
Public Const IDC_IBEAM = 32513&
Public Const IDC_ICON = 32641&
Public Const IDC_NO = 32648&
Public Const IDC_SIZE = 32640&
Public Const IDC_SIZEALL = 32646&
Public Const IDC_SIZENESW = 32643&
Public Const IDC_SIZENS = 32645&
Public Const IDC_SIZENWSE = 32642&
Public Const IDC_SIZEWE = 32644&
Public Const IDC_UPARROW = 32516&
Public Const IDC_WAIT = 32514&
Public Const IDC_HELP = 32651&

Declare Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
(ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

Declare Function LoadCursorFromFile Lib "user32" Alias _
"LoadCursorFromFileA" (ByVal lpFileName As String) As Long

Declare Function SetCursor Lib "user32" _
(ByVal hCursor As Long) As Long

Function MouseCursor(CursorType As Long)
Dim lngRet As Long
lngRet = LoadCursorBynum(0&, CursorType)
lngRet = SetCursor(lngRet)
End Function

Function PointM(strPathToCursor As String)
Dim lngRet As Long
lngRet = LoadCursorFromFile(strPathToCursor)
lngRet = SetCursor(lngRet)
End Function
'----- end of code for module basMouseCursor -----

Then, instead of

DoCmd.Hourglass True

write

MouseCursor IDC_WAIT

That seems to work the same for labels and buttons. In my test, I found
that executing

DoCmd.Hourglass False

set the cursor back to normal, regardless of how I set it to the
hourglass shape.
 

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