Solved

Multiple fields in OrderBy (VBA)

Posted on 2008-10-27
5
713 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
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…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
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…

786 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