Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW TO CHANGE MOUSE POINTER TO AN HOURGLASS WHILE WAITING FOR EVENT TO 2

Status
Not open for further replies.

Hiccup

Programmer
Jan 15, 2003
266
US
Can someone provide me with the code to change the MousePointer to the Hourglass symbol after clicking a Command Button. When accessing an Adodc recordset of Access2K, it sometimes takes a couple of seconds before the Form containing the DataGrid will display. I would like for the user to see the Hourglass while waiting for the DataGrid Form to appear.

Thanks in advance!
 
me.mousepointer = 11

to set it back to normal use

me.mousepointer = 0
 
Thanks Harleyquinn, that seems incredibly simple, but I'll try it. I found the code below to do it in one of my VB6 reference books, but it doesn't work.

Private lOrigPointer As Long
Private vUseObject As Variant
Public Sub SetCursor(Optional UseObject As Variant, Optional Pointer As Variant)
Dim lNewPointer As Long
On Error Resume Next
'Save the current cursor
If IsMissing(UseObject) Then
lOrigPointer = Screen.MousePointer
Else
lOrigPointer = UseObject.MousePointer
Set vUseObject = UseObject
End If
'Default to Hourglass
lNewPointer = vbHourglass
If Not IsMissing(Pointer) Then
If IsNumeric(Pointer) Then
'Substitute with your own pointer if needed
lNewPointer = Pointer
End If
End If
'Set the pointer
If IsMissing(UseObject) Then
Screen.MousePointer = lNewPointer
Else
UseObject.MousePointer = lNewPointer
End If
End Sub
Private Sub Class_Terminate()
On Error Resume Next
'Restore Pointer
If IsEmpty(vUseObject) Then
Screen.MousePointer = lOrigPointer
Else
vUseObject.MousePointer = lOrigPointer
End If
End Sub
 
Hiccup

or you can use the VB constants:

Screen.MousePointer = vbHourGlass
Screen.MousePointer = vbDefault


Tom (maxflitom)
 
Thanks you two. I used Harleyquinn's suggestion and it works great!!

A star for both of you, thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top