Sorting a subform

  • Thread starter Thread starter Jerry
  • Start date Start date
J

Jerry

what is the code for sorting a field in a query. i want
the user to be able to click a command button and sort the
specified field either A-Z or Z-A, without right clicking
and selecting sort from there.

thanks,

jB
 
If the command button is on the subform then create a click event which uses
a module level boolean variable to toggle the sort order:

'In module header
dim fDescending as boolean
'
Private Sub cmdSort_Click()
If fDescending Then
Me.OrderBy = "CompanyName Desc"
Else
Me.OrderBy = "CompanyName Asc"
End If
Me.OrderByOn = True
fDescending = Not fDescending
End Sub
 
Back
Top