Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Sort records ascending / descending using same command button

Posted on 2003-03-28
2
Medium Priority
?
820 Views
Last Modified: 2006-11-17
Dear experts, I would like to sort records ascending and descending in a continuous form using a single command button. I.e. click once to sort ascending and click again to sort descending. Sounds easy, but then I've said that before! Using Access 97. Help appreciated.
0
Comment
Question by:Rich292
2 Comments
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 200 total points
ID: 8225257
You can do something like this in your command button:
If IsNull(Me.OrderBy) Or Me.OrderBy="[MyField] DESC" Then
   Me.OrderBy = "[MyField]"
Else
   Me.OrderBy = "[MyField] DESC"
End If
Me.OrderByOn = True

The above code switches the ordering from ascending to descending depending on the current sort order (DESC orders the field descending). MyField is the name of the field that you want to order on.

HTH!
0
 
LVL 2

Author Comment

by:Rich292
ID: 8225891
Fantastic! What a great start to the weekend. Many thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question