Solved

Populate access combo box with month name and year from data table.

Posted on 2016-07-19
12
129 Views
Last Modified: 2016-07-19
I have 32000 records in my table and I need my monthly report to show me all records for the month of June 2016 for example, or January 2015, just by selecting "January 2015" from combo box. This combo box needs to be sequentially populated when opening a report and if a new month is detected to add it to combo box.

Any help is appreciated.
0
Comment
Question by:toalexsandr
[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
  • 6
  • 4
  • 2
12 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41719416
i'll assume you have a date field in your table, so use this as the rowsource of your combo box

select format([dateField], "mmmm yyyy")  from tableName
group by  format([dateField], "mmmm yyyy")
 order by  [dateField]

use a query as recordsource of your form/report using the value of the selected item form the combo box

select * from tableName
where  format([dateField], "mmmm yyyy") = Forms!NameofForm.NameofCombo
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 41719469
From a usability stand point, consider what will happen if your application is used for 3, 5, 10 years. Think about the number of entries that will appear in the combo box. You may want to consider using two combo boxes, one for Month that you fill will all months, and one for year that you pull from your data.
0
 

Author Comment

by:toalexsandr
ID: 41719573
Rey here is what I had to use because of errors but its not sorting it properly...

SELECT Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy") AS InspDate
FROM tb_WOInspectionNAS
GROUP BY Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy")
ORDER BY Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy");

April 2016
August 2015
December 2015
February 2016
January 2016
July 2015
July 2016
June 2015
June 2016
March 2016
May 2016
November 2015
0
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!

 

Author Comment

by:toalexsandr
ID: 41719575
Shaun, its a good point. I think i may need to do that down the road.
0
 
LVL 26

Expert Comment

by:Shaun Kline
ID: 41719580
If you want to sort your dates in calendar order, change for your format in the order by to something like "yyyy-mm-dd". The group by may not like that though.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41719588
change the field in the order by

SELECT Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy") AS InspDate
FROM tb_WOInspectionNAS
GROUP BY Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy")
ORDER BY [tb_WOInspectionNAS].[QC Inspection Date]
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41719591
change the field in the order by

SELECT Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy") AS InspDate
FROM tb_WOInspectionNAS
GROUP BY Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy")
ORDER BY Format([tb_WOInspectionNAS].[QC Inspection Date] , "yyyy mm")
0
 

Author Comment

by:toalexsandr
ID: 41719592
i get this error "You tried to execute a query that does not include the specified expression '[tb_WOInspectionNAS].[QC Inspection Date]' as part of an aggregate function."
0
 

Author Comment

by:toalexsandr
ID: 41719593
nothing. same error.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 41719596
SELECT Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy") AS InspDate
FROM tb_WOInspectionNAS
GROUP BY Format([tb_WOInspectionNAS].[QC Inspection Date],"mmmm yyyy"), Format([tb_WOInspectionNAS].[QC Inspection Date] , "yyyy mm")
ORDER BY Format([tb_WOInspectionNAS].[QC Inspection Date] , "yyyy mm")
0
 

Author Comment

by:toalexsandr
ID: 41719605
Worked perfect...Thanks a lot.

June 2015
July 2015
August 2015
November 2015
December 2015
January 2016
February 2016
March 2016
April 2016
May 2016
June 2016
July 2016
0
 

Author Closing Comment

by:toalexsandr
ID: 41719606
Works perfect. Thanks.
0

Featured Post

Technology Partners: 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

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…
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.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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