[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

MS Access query date sorting question

Posted on 2016-11-17
7
Medium Priority
?
53 Views
Last Modified: 2016-11-17
I have a simple query and I can't figure out how to first sort the data by year then by month
TEST_DB.accdb
Sort.png
0
Comment
Question by:cssc1
[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
  • 3
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41892070
try this

SELECT tblContact.ContactID, tblGoodCatch.GoodCatchNo, tblContact.LastName, tblContact.FirstName, tblContact.JobTitle, tblContact.Foreman, tblContact.Shift, tblGoodCatch.GoodCatchDescription, tblGoodCatch.GoodCatchMonthlyWinner, tblContact.Terminated, tblGoodCatch.GoodCatch_NearMiss, tblGoodCatch.Date_, tblGoodCatch.Month___, tblGoodCatch.Year__, tblGoodCatch.SubmittedGC, tblGoodCatch.SubmittedNM
FROM tblContact INNER JOIN tblGoodCatch ON tblContact.ContactID = tblGoodCatch.GoodCatchNo
ORDER BY tblGoodCatch.Year__, tblGoodCatch.Date_;
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41892072
if you want to sort by Year, Month, use this

ORDER BY tblGoodCatch.Year__, tblGoodCatch.Month___
0
 

Author Comment

by:cssc1
ID: 41892124
Sorry, but where do I put this code that you have provided?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 41892128
here see query_Year_Date, query_Year_Month
TEST_DB_rev.accdb
0
 

Author Comment

by:cssc1
ID: 41892161
Work fine, thanks!
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 41892162
Notice that Month__ was added a second time to the grid but the show box is unchecked.  If you rearrange the grid to have year to the left of month, you don't need to repeat the month field.qrySort.JPG
Rather than using some number of underscores as a suffix, why not use a meaningful prefix to avoid conflict with reserved words?

CatchDate, CatchMonth, CatchYear.

Also, why are year and month separate from date?  Given their data content they don't seem to have any relationship to CatchDate so perhaps some prefix other than "Catch" makes more sense.
0
 

Author Closing Comment

by:cssc1
ID: 41892163
Works fine, thanks!
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

649 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