Report Sorting

Galstar

New member
Local time
Today, 08:00
Joined
Feb 24, 2005
Messages
6
I have this code executing upon Open report procedure. All vales are coming from a form. it sorts by default Asc so of course that works. But the sorting by desc is not working. Anyone have a reason why?

***Code Starts Here******

Dim SortedBy As String

SortedBy = [Forms]![Reports]![Sort]

SortedBy = "[" & SortedBy & "]"

If Forms!Reports!Math = "<" Then
Reports.RPT_AFPT_Results.RecordSource = "qry_APFT_Results"
Else
Me.RecordSource = "qry_APFT_ResultsII"
End If

If Forms!Reports![SortOrder] = 1 Then
Me.OrderByOn = True
Me.OrderBy = SortedBy
Else
Me.OrderByOn = True
Me.OrderBy = SortedBy
Me.OrderBy = desc
End If
 
Last edited:
You have replaced the entire contents of OrderBy with "desc". The OrderBy clause needs to include the fields to sort by as well as desc.

fldA Desc, fldB, fldC Desc

Notice that each field that needs to be ordered descending must have its name followed by Desc.
 
Pat Hartman said:
You have replaced the entire contents of OrderBy with "desc". The OrderBy clause needs to include the fields to sort by as well as desc.

fldA Desc, fldB, fldC Desc

Notice that each field that needs to be ordered descending must have its name followed by Desc.


If that was the case then:

Me.OrderBy = SortedBy desc

would work, and it does not. The SortedBy value = [Last Name]
 

Users who are viewing this thread

Back
Top Bottom