Others

How to Filter an Access Crosstab Subform by Year with a Combo Box

Camila MilosovichCamila Milosovich Nov 2, 2026 869 views

Question details

The user needs to filter a Microsoft Access crosstab query displayed in a subform based on a year selected from a combo box on the main form.

How to Filter an Access Crosstab Subform by Year with a Combo Box
Product
Microsoft Access
Device & OS
not provided
Scenario
Dynamically filtering a crosstab query subform using a user-selected value from a combo box dropdown.
Observed behavior
Linking the combo box to the subform and adding query criteria fails to display the filtered crosstab results because the parameters are not explicitly declared in the SQL.
Before you start

Verify whether the Year field in your database table is stored as a numeric value (e.g., Short) or text, as this dictates the exact parameter data type needed in your SQL query.

Solution 1Recommended

Declare SQL Parameters and Add a WHERE Clause

Explicitly declaring parameters in the crosstab query's SQL view ensures Access recognizes the combo box value as a valid filter criterion.

Unlike standard queries, crosstab queries in Access require explicit parameter declarations to evaluate form controls. Without this, Access cannot determine the data type of the filter criteria before pivoting the data.

1
Open the Crosstab Query in SQL View

Right-click your crosstab query in the Access Navigation Pane and select 'SQL View' to see the raw query text.

2
Declare the Parameter

At the very top of your SQL statement, directly before the TRANSFORM clause, declare the parameter that references your form control. For example: PARAMETERS [Forms]![SELCROSS]![SELYEAR] Short;

3
Add the WHERE Clause

Insert a WHERE clause immediately after your FROM statement to filter the dataset before it is grouped. For example: WHERE MONTHLY2.Year=[Forms]![SELCROSS]![SELYEAR].

4
Requery the Subform on Update

Open your main form in Design View, select the combo box, and add an Event Procedure to the 'After Update' property. Use the VBA code Me.SubformControlName.Requery to refresh the subform data whenever the combo box selection changes.

Declare SQL Parameters and Add a WHERE Clause
Check the Bound Column: Ensure that the bound column of your combo box contains the actual data being passed to the query. If column 2 holds the years, ensure the bound column property is set to 2.
Free Microsoft Office alternative

Looking for a Free Alternative to Microsoft Office?

While Microsoft Access handles complex relational databases, for everyday data management, robust data analysis, and documentation, WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Word, Excel, and PowerPoint.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installation package for your PC or Mac.
  2. 2. Install the Software: Run the installer and follow the quick setup wizard to install the full suite in minutes.
  3. 3. Open and Edit Files: Launch WPS Office to effortlessly create, edit, and share your documents, spreadsheets, and presentations.
Highly compatible with Microsoft Office formats (docx, xlsx, pptx)Free, lightweight, and fast installationAdvanced Spreadsheets features for robust data analysis and pivot tablesFamiliar user interface for seamless migration without a learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't my crosstab query filter automatically when linked to a combo box?

Unlike standard SELECT queries, Access crosstab queries cannot automatically resolve form references in their criteria. You must explicitly declare the form reference as a parameter with a defined data type before the TRANSFORM statement.

What data type should I use for a year parameter in Access?

If your Year field is stored as a number, use 'Short' or 'Long' integer data types in your PARAMETERS declaration. If the year is stored as text, declare it as 'Text (255)' instead.

Why is the subform still blank after I select a year from the dropdown?

The subform must be explicitly refreshed to display the new filtered data. You can fix this by adding a simple VBA command like 'Me.SubformName.Requery' to the 'After Update' event of your combo box control.