Solved

Multiple fields in OrderBy (VBA)

Posted on 2008-10-27
5
734 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 - Microsoft MVP, Access and Data Platform) 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

697 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