Hourglass does not work

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi! I'm trying to run some simple code that re-sorts the data in a form that
I am viewing when I click on a field label but I cannot get the cursor to
change to an hourgalss. I have tried putting it in both subs and I tried
putting it just in the "click" sub or just in the "SetOrderBy" sub but
nothing seems to work! What am I doing wrong?

-----------------------------------------------------------------------------
Private Sub SetOrderBy(newOrderBy As String)
DoCmd.Hourglass True
Dim curOrderBy, AscDesc As String
curOrderBy = Me.OrderBy & " "
curOrderBy = Left(curOrderBy, InStr(curOrderBy, " ") - 1)
AscDesc = IIf(UCase(Right(RTrim(Me.OrderBy), 4)) = "DESC", "", " DESC")

If curOrderBy <> newOrderBy Then AscDesc = ""

Me.OrderBy = newOrderBy & AscDesc
Me.OrderByOn = True
DoCmd.Hourglass False
End Sub
-----------------------------------------------------------
Private Sub excp_cret_dt_Label_Click()
SetOrderBy ("excp_cret_dt")
End Sub
-----------------------------------------------------------------------
Private Sub excp_num_Label_Click()
DoCmd.Hourglass True
SetOrderBy ("excp_num")
DoCmd.Hourglass False
End Sub
 
Molasses,

Unless you have a very large number of records, or complicated
calculations in the form's record source, or some such, I would expect
this code to work very fast. Maybe it happens so fast you don't see the
hourglass?

By the way, just in case you're interested in a simplification of your
code, this is how I would have approached it...

Private Sub SetOrderBy(newOrderBy As String)
If Me.OrderBy = newOrderBy Or Me.OrderBy = newOrderBy & " DESC" Then
' do nothing
Else
Me.OrderBy = newOrderBy
End If
Me.OrderByOn = True
End Sub
 
Back
Top