Link to home
Start Free TrialLog in
Avatar of Addie Baker
Addie BakerFlag for United States of America

asked on

Filter Report by Combo Box in Access

i have a report that i would like to sort by selecting a value from a combobox

the combo box needs to be bound to unique records from a table (there are only 5 differet choices)

the report format stays the same just the data is dependent on what the value of the combobox is.
Avatar of mbizup
mbizup
Flag of Kazakhstan image

You can set criteria for your report in the openreport statement, using your combo box:

Docmd.openreport YourreportName,acviewpreview,,"ID = " & me.cboYourCombo

Alternatively, you can set criteria in the recordsource query of your report using a WHERE clause:

SELECT * from YourTable WHERE ID = Forms!YourFormName!YourComboName
Avatar of Addie Baker

ASKER

recordsource query of your report
where is this??
okay i found that, but i would like the combo box to be on the report. so when you are looking at the report the combo box can be changed and the new info be printed
I don't have a copy of Access 2007 at the moment, and this sort of thing is not possible in earlier versions.

If Access 2007 Allows this type of functionality I imagine it would be similar to controling a form's filter property through a combo box. If that is the case, you would need code like this in the AfterUpdate event of your combo box:

Me.Filter = "ID = " & me.cboMyCombo
me.filteron = TRUE
where do i put my combo box on the report?
header?
detail?
Try the header.

Again, I've got my doubts about this. I know A2K7 gives reports some more functionality - but I don't have a copy at the moment to try this out myself.

In A2k3, you would place the combo box on a form and open a filtered report through that form.
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial