How to Filter an Access Crosstab Subform by Year with a Combo Box
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.

- 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.
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.
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.
Right-click your crosstab query in the Access Navigation Pane and select 'SQL View' to see the raw query text.
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;
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].
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.

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. Download WPS Office: Visit the official WPS website and download the free installation package for your PC or Mac.
- 2. Install the Software: Run the installer and follow the quick setup wizard to install the full suite in minutes.
- 3. Open and Edit Files: Launch WPS Office to effortlessly create, edit, and share your documents, spreadsheets, and presentations.

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.




