Solved

Multiple fields in OrderBy (VBA)

Posted on 2008-10-27
5
683 Views
Last Modified: 2012-05-05
Hi Everyone,
Is it possible to have multiple sort criteria in an "OrderBy" statement?  I would like to sort first by date, then by time, but when I try to add time to my code, I get an "expected end of statement" error.
I tried ... OrderBy = "Date", "Time" when I received the error.
This is what I have now, but it does not sort by time:
...
JobTrailerSummaryTable_subform.Visible = True
JobTrailerSummaryTable_subform.Form.OrderBy = "Date"
JobTrailerSummaryTable_subform.Form.OrderByOn = True
...

Any Ideas?
0
Comment
Question by:Andy419
  • 3
5 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 250 total points
ID: 22817033
JobTrailerSummaryTable_subform.Visible = True
JobTrailerSummaryTable_subform.Form.OrderBy = "Date, Time"   ' separate by comma
JobTrailerSummaryTable_subform.Form.OrderByOn = True
0
 
LVL 75
ID: 22817044
You may need brackets also:


JobTrailerSummaryTable_subform.Form.OrderBy = "[Date], [Time]"   ' separate by comma
0
 

Author Closing Comment

by:Andy419
ID: 31510531
THANKS -- That was it!!!
0
 
LVL 8

Expert Comment

by:fabriciofonseca
ID: 22817050
You can do it using SQL but my suggestion is always to build a form upon a query, thus you can go to the query and easily filter or order by and it will be automaticaly reflected into the form.


Regards
0
 
LVL 75
ID: 22817051
Also ... not a good idea to have field names such as Date and Time, since these are Access Reserved Words.

mx
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now