Order by on form open

G

Guest

Private Sub DateOfServiceLabel_Click()
If Right(Me.OrderBy, 4) = "DESC" Then
Me.OrderBy = "[DateOfService]"
Else
Me.OrderBy = "[DateOfService]" & " DESC"
End If
Me.OrderByOn = True
Me.OrderByOn = True
-------------------------------------------------------------
Private Sub DoctorLabel_Click()
If Right(Me.OrderBy, 4) = "DESC" Then
Me.OrderBy = "[Doctor]"
Else
Me.OrderBy = "[Doctor]" & " DESC"
End If
Me.OrderByOn = True
Me.OrderByOn = True

I use these codes on the on click event of the labels of the corresponding
bound text boxes in the detail section of a continous form. There are a
total of 5 lables to resort by. My problem is that the form opens according
to the last me.orderby sort, not the Sort: section of the underlying query.
Each time the form is open I want the default order by to be the same as the
Sort: [DateOfService] in the query "ChartTotalUnbillable". Any help is
needed!?
 
G

George Nicholson

In Form_Close() and/or Form_Open:
Me.OrderBy = """

That should let the underlying query determine the initial sort order.

HTH,
 
G

Guest

I was able to the this to work in the on close event of the form
Me.OrderBy = ""
However, this seems to requery the form before it closes. Is this the case?
This Orderby takes a good 20-30 seconds due to the amount of data behind it
so I am trying to prevent a requery/resort in the on open or on close event.

George Nicholson said:
In Form_Close() and/or Form_Open:
Me.OrderBy = """

That should let the underlying query determine the initial sort order.

HTH,

Ryan Tisserand said:
Private Sub DateOfServiceLabel_Click()
If Right(Me.OrderBy, 4) = "DESC" Then
Me.OrderBy = "[DateOfService]"
Else
Me.OrderBy = "[DateOfService]" & " DESC"
End If
Me.OrderByOn = True
Me.OrderByOn = True
-------------------------------------------------------------
Private Sub DoctorLabel_Click()
If Right(Me.OrderBy, 4) = "DESC" Then
Me.OrderBy = "[Doctor]"
Else
Me.OrderBy = "[Doctor]" & " DESC"
End If
Me.OrderByOn = True
Me.OrderByOn = True

I use these codes on the on click event of the labels of the corresponding
bound text boxes in the detail section of a continous form. There are a
total of 5 lables to resort by. My problem is that the form opens
according
to the last me.orderby sort, not the Sort: section of the underlying
query.
Each time the form is open I want the default order by to be the same as
the
Sort: [DateOfService] in the query "ChartTotalUnbillable". Any help is
needed!?
 
G

Guest

Is the method to reseting the Oderby propert basicly forcing a requery in the
Reset the OrderBy property on close?

Steve

Ryan Tisserand said:
Private Sub DateOfServiceLabel_Click()
If Right(Me.OrderBy, 4) = "DESC" Then
Me.OrderBy = "[DateOfService]"
Else
Me.OrderBy = "[DateOfService]" & " DESC"
End If
Me.OrderByOn = True
Me.OrderByOn = True
-------------------------------------------------------------
Private Sub DoctorLabel_Click()
If Right(Me.OrderBy, 4) = "DESC" Then
Me.OrderBy = "[Doctor]"
Else
Me.OrderBy = "[Doctor]" & " DESC"
End If
Me.OrderByOn = True
Me.OrderByOn = True

I use these codes on the on click event of the labels of the corresponding
bound text boxes in the detail section of a continous form. There are a
total of 5 lables to resort by. My problem is that the form opens according
to the last me.orderby sort, not the Sort: section of the underlying query.
Each time the form is open I want the default order by to be the same as the
Sort: [DateOfService] in the query "ChartTotalUnbillable". Any help is
needed!?
 

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