Sorting a subform

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
 
S

Sandra Daigle

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
 

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