?
Solved

Sort records ascending / descending using same command button

Posted on 2003-03-28
2
Medium Priority
?
810 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

800 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