Link to home
Start Free TrialLog in
Avatar of JakeB52
JakeB52

asked on

How to populate report based on criteria specified in form?

Hello Experts,

I have noticed several references to this subject but I’m having trouble creating a solution that meets my needs.

My goal is to have a form that allows the user to select the criteria used to filter an existing query and populate the report based on the results of that query.

In Access 2000 I have a query called “qryReport”. This query contains several expressions that generate a master record set of all the data I need for my reports.

The report is called “rptReport”.  It contains selected fields found in qryReport. These fields will not change on the report (at least for now).

Finally, I have a form that contains about 30 text, combo and checkbox objects that will be used to filter data found in qryReport and populate the report. I also have a combobox that allows users to sort data based on the fields represented in the report.

I will also be looking into exporting this report as and Excel spreadsheet. I’m not looking for a solution for this particular feature right now, but I thought I’d mention my future plans in case it impacts the solution.

I have tried sending parameters to qryReport, modifying the record source in rptReport on the fly, and applying filters to rptReport but I keep running into roadblocks.  

I’m looking for a solution that can easily be managed if the criteria on the form must change.

Any suggestions or samples would be greatly appreciated.

Thanks.
Avatar of CrossWired
CrossWired

I put this

   Me.Filter = Forms.frmProjectSummary.Filter
   Me.FilterOn = Forms.frmProjectSummary.FilterOn
   Me.OrderBy = Forms.frmProjectSummary.OrderBy
   Me.OrderByOn = Forms.frmProjectSummary.OrderByOn

In my Report OnOpen and it pulls the sort order and filter properties from my Project Summary Form.
Avatar of JakeB52

ASKER

Thanks CrossWired.

I should add that the information collected on my form may not exactly reflect the text that I'm filtering. For example, a combobox may have a list of countries, and even though "Germany" may appear as the selected item to the user, I'm actually filtering based on the country's id ( cboCountry.Column(0) ). The data contained in my combobox may look something like this:

24;Germany;Allemagne;Deutschland;Germania

whereas the item that appears to the user will depend on the language mode he/she is using.

So overall, I would prefer not to depend on the data that is displayed on the form to filter my report.
 
On the form you would have to setup the filter correctly, I use 2 ComboBoxes to set the different filter criteria and once my project summary shows the right info, I hit a button and it pulls up the correct report.  If you need an example of my form filtering code let me know.

Jay
Avatar of JakeB52

ASKER

A code sample would be helpful. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of CrossWired
CrossWired

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
Avatar of JakeB52

ASKER

CrossWired,

My apologies for not getting back to your sooner... I came across a few issues while generating my reports that were not directly related to this posting. Your suggestions worked great. Thank you very much!
no problem, it got you going so everyoen is happy