Chart & Visualization Issues

Filter a Microsoft Access Chart by Day, Week, or Month

Natalie TaylorNatalie Taylor Nov 20, 2026 870 views

Question details

Create an Access dashboard chart that switches between daily, weekly, and monthly product counts when a user selects an option.

Filter an Access Chart by Day, Week, or Month
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.
Before you start

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.

Solution 1Recommended

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.

1
Add the option group

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.

2
Check the chart fields

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.

3
Add the VBA procedure

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

4
Connect and test the events

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.

Use an option group and VBA to regroup the Access chart
Adjust the count if needed: Count([ProductID]) excludes records with a blank product ID. To total units from a quantity field instead, replace it with Sum([Quantity]) and use your actual quantity field name.
Free Microsoft Office alternative

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.

Create spreadsheet charts from exported sales data.Open and edit Microsoft Excel XLSX workbooks.Use a familiar spreadsheet interface for an easier transition.Work with a free, lightweight Office alternative.
microsoft office alternative - wps office

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.