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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort Detail Section at Runtime

Status
Not open for further replies.

emtenzer

MIS
Nov 14, 2001
50
US
I have a report being run by a form which offers different sort options. There is one group in the report - call it "Status". I need the users to be able to sort within the status by "client name" or "days past due". I'm having no luck. The sort order is being offered by a combo box. Currently I have this on the On Format of the detail section in the report:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Forms!frmPastDueLoans!cboSort = "Days Past Due" Then

Me.OrderBy = [days]
Me.OrderByOn = True

Else
If Forms!frmPastDueLoans!cboSort = "Client Name" Then
Me.OrderBy = [Name]
Me.OrderByOn = True

End If
End If
End Sub


Any insight would be greatly appreciated. Thank you.
 
First, I think you have to have OrderByOn turned on before you can set OrderBy (but not certain).
Second, MS Help says OrderByOn should = yes; I'm pretty sure true ought to work anyhow, since they are both Boolean reserved words that ought to evaluate to -1.

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Thanks. I changed the true to "Yes" and moved the OrderByOn to be first but it didn't make a difference.
 
Try putting your code on the report's on open event instead.

Also you should set the orderby to a string (double quotes around the field names in code).
 
Thank you! It worked! I really appreciate the extra eyes!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top