Full Version: Two Criteria To Filter Data To Print
UtterAccess Discussion Forums > Microsoft® Access > Access Reports
foxtrojan
Can we have a dialog box that can filter a Report with two criteria, like By [1] Customer by [2] Products. ?
Kamulegeya
QUOTE (foxtrojan @ May 17 2012, 12:01 PM) *
Can we have a dialog box that can filter a Report with two criteria, like By [1] Customer by [2] Products. ?



Hello

Create a form with two combo boxes..

1: Customers( ID and Name). Count;2. Width:0,2
2 : Productes(ID and name)Count;2. Width:0,2

Suppose your report displays custome name and product name

Add a button on the form to open the report

CODE
DoCmd.OpenReport "rptName", acViewPreview, , "[CustomeName]='" & Me.CustomerComboBox.Column(1) & "'" & "and [ProductName]='" & Me.ProductCombobox.Column(1) & "'"


Ronald
foxtrojan
Thanks so much Ronald. Works perfectly. Is it possible to select multi Customers?
JonSmith
Look into something called Query By Form. It should point you in the right direction.
There is an excellent example in the code archives with a topic title of something like 'Query By Form Using Class Modules'
Kamulegeya
QUOTE (foxtrojan @ May 17 2012, 07:33 PM) *
Thanks so much Ronald. Works perfectly. Is it possible to select multi Customers?



Hello

It is possible using a multi- select list box instead of a combo box for the customers

Make a list box with two columns as in the combo box . Width assume 0,2

In the list box other tab( in design view) set the multi select property to Extended


Here is the air code for button

CODE
Dim varItem as variant

For each varItem in Me.ListBoxName.ItemsSelected
DoCmd.OpenReport "rptName", acViewPreview, , "[CustomeName]='" & Me.CustomerComboBox.Column(1,varItem) & "'" & "and [ProductName]='" & Me.ProductCombobox.Column(1) & "'"

next varItem


try and tweak accordingly to work

Ronald




foxtrojan
Thanks Ronald, works perfectly. Everybody happy.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.