Filter a Microsoft Access Chart by Day, Week, or Month
Question details
Create an Access dashboard chart that switches between daily, weekly, and monthly product counts when a user selects an option.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A dashboard form uses Day, Week, and Month option buttons to change how sales dates are grouped in a chart.
- Observed behavior
- The chart should automatically display the count of product records for each selected date period.
Identify the sales table, date field, product field, and chart control names in your Access database. The example below counts nonblank product IDs per record; if a record contains a quantity greater than one, use a quantity sum instead.
Use an option group and VBA to regroup the Access chart
Use this approach when the chart should update immediately after a user selects Day, Week, or Month.
The example groups all available sales dates into periods; it does not restrict the chart to a particular date range. Weeks start on Monday, and monthly periods start on the first day of the month.
Open the dashboard form in Design View and add an Option Group named grpPeriod. Add Day, Week, and Month option buttons with Option Value properties of 1, 2, and 3 respectively. Set the group’s Default Value to 1.
Name the chart control chtSales. In its property sheet, set Row Source Type to Table/Query. Configure the chart to use PeriodStart as its category or axis field and ProductsSold as its value field; these aliases are returned by the VBA query.
Open the form’s property sheet, select the Event tab, and use the builder for an event to open the form’s VBA module. Add this code, replacing Sales, SaleDate, ProductID, grpPeriod, and chtSales with your actual names where necessary: Private Sub UpdateSalesChart() Dim periodExpr As String Dim sql As String Select Case Nz(Me!grpPeriod, 1) Case 1 periodExpr = "DateValue([SaleDate])" Case 2 periodExpr = "DateAdd('d', 1 - Weekday([SaleDate], 2), DateValue([SaleDate]))" Case 3 periodExpr = "DateSerial(Year([SaleDate]), Month([SaleDate]), 1)" Case Else Exit Sub End Select sql = "SELECT " & periodExpr & " AS PeriodStart, " & _ "Count([ProductID]) AS ProductsSold FROM [Sales] " & _ "WHERE [SaleDate] Is Not Null GROUP BY " & periodExpr & _ " ORDER BY " & periodExpr Me!chtSales.RowSource = sql Me!chtSales.Requery End Sub Private Sub grpPeriod_AfterUpdate() UpdateSalesChart End Sub Private Sub Form_Load() UpdateSalesChart End Sub
In the property sheet, set the option group’s After Update event and the form’s On Load event to [Event Procedure]. Save the form, open it in Form View, and select each option to check that the chart refreshes.

Chart Exported Access Sales Data in WPS Spreadsheet
WPS Office is a free, lightweight alternative with a familiar interface and Microsoft Office format compatibility. Export Access data to an Excel workbook, then open it in WPS Spreadsheet for charting; WPS does not run or repair the Access form’s VBA.

Frequently Asked Questions
Does selecting Month show only the current month?
No. In this example, Month groups all available records by month. Add date conditions to the SQL WHERE clause if you also need to limit the chart to a specific range.
How are weeks defined in the VBA example?
Each week starts on Monday. The query calculates the Monday date for each sale and uses that date as the weekly chart category.
Why does the chart count differ from the number of units sold?
Count([ProductID]) counts records with a nonblank product ID, not quantities. If each record has a quantity field, replace the count expression with Sum([Quantity]) using your actual field name.
Can I create the chart in a spreadsheet instead of Access?
Yes. In Access, use External Data > Export > Excel to export the relevant data, then open the workbook in Excel or WPS Spreadsheet and create a chart. This does not reproduce the Access option-button VBA automatically.




