report based on filter

  • Thread starter Thread starter diederik
  • Start date Start date
D

diederik

hi all,

I want to create a report that is based on a filter.
the filter is a form wih two fields (comboboxes)

when I open the report I want it to filter on the two
(or one if there is only one filled) fields of the form.

I have the form.
I can add a button to the form to open the report
but I don't know how to use the data on the form as filter criteria for the
report.

Thanks in advance

Diederik

p.s. I know very little of visual basic so work mostly with the property
boxes and wizzards
 
There are a couple of ways. You can pass the filter in the DoCmd.OpenReport
call as the Where Condition argument. You can have the query feeding the
report refer to the controls on the form in the WHERE clause of the query.

To refer to controls on a form from a location other than that form you
would use syntax similar to

Forms!FormName!ControlName

The form has to be open for this to work, although it can be hidden if you
prefer. So, if this was the criteria in a query, it would be something like

SELECT * FROM Table1 WHERE Table1.Field1=Forms!FormName!ControlName
 
Back
Top