Reputation: 29
I have a report based on a query that groups data per date.
Now I want to create a form with two combobox YEAR and MONTHS. Then let user select criteria from these combobox and upon clicking on a button, the report would open with only data from the selected criteria.
Can someone help me with the vba code that should be on the click event of the button?
Upvotes: 0
Views: 132
Reputation: 55806
You can add a criteria when you open the report:
DoCmd.OpenReport "YourReport", , , "[DateField] => DateSerial(" & Me![Year].Value & ", " & Me![Month].Value & ", 1) And [DateField] < DateSerial(" & Me![Year].Value & ", " & Me![Month].Value & " + 1, 1)"
Replace Year, Month, etc. with the actual names of your controls.
Upvotes: 1