Solved

Multiple fields in OrderBy (VBA)

Posted on 2008-10-27
5
753 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
[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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

687 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