Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
how to custom sort in vba
Vanesai 

16 years ago
I am an advanced user and I have a form based on a query that I'd like to custom sort in VBA. The only way I know how to do this is with the OrderBy and OrderByOn commands. Yet the OrderBy command only accept parameters and not values, so I can't use a SWITCH/IIF statement like I would in an SQL query.

In short, how do I go about sorting the following values such that anything "CONFIRMED" OR "PENDING" will show up at the top of the list:


CONFIRMED
PENDING
CANCELLED
NOT IN LIST
DUPLICATE

Any help would be appreciated. Thank you in advance.

-Vanesai


Answer from Richard Rost:

What I would do is to create a table with your values and their preferred sort order.

1, Confirmed
2, Pending
3, Cancelled
etc.

Then, create a link between your data table and this status table. You can then use the Sort Order field to control which records sort in what order.

Now personally, I like controlling the sort order of FORMS by changing the RecordSource property.

Me.RecordSource = "SELECT * FROM MyTable ORDER BY SortOrderID"

That's just me. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/22/2026 1:00:40 PM. PLT: 1s