If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Getting a report to ignore parameters
I have a database holding details of students and training courses. One of
the reports produces stats for selected years and selected category of courses, the year and category being set as parameters in the underlying query. The parameters are selected by the user from a combo box on a form. What I would like to do is give the user the option of selecting 'All Categories' in the combo box and the report therefore, effectively ignore this parameter, i.e. produce a report for a selected year but showing stats for all categories of course. How would I do it? TIA Martin Watts |
#2
|
|||
|
|||
Assuming that your query has a parameter similar to this:
Forms!FormName!ComboBoxName Just replace it with this (assuming that the combo box is blank when you want all records): Forms!FormName!ComboBoxName Or Forms!FormName!ComboBoxName Is Null -- Ken Snell MS ACCESS MVP "Martin Watts" wrote in message ... I have a database holding details of students and training courses. One of the reports produces stats for selected years and selected category of courses, the year and category being set as parameters in the underlying query. The parameters are selected by the user from a combo box on a form. What I would like to do is give the user the option of selecting 'All Categories' in the combo box and the report therefore, effectively ignore this parameter, i.e. produce a report for a selected year but showing stats for all categories of course. How would I do it? TIA Martin Watts |
#3
|
|||
|
|||
Excellent. Thanks for that Ken, works like a dream. Martin Watts "Ken Snell [MVP]" wrote in message Assuming that your query has a parameter similar to this: Forms!FormName!ComboBoxName Just replace it with this (assuming that the combo box is blank when you want all records): Forms!FormName!ComboBoxName Or Forms!FormName!ComboBoxName Is Null "Martin Watts" wrote in message ... I have a database holding details of students and training courses. One of the reports produces stats for selected years and selected category of courses, the year and category being set as parameters in the underlying query. The parameters are selected by the user from a combo box on a form. What I would like to do is give the user the option of selecting 'All Categories' in the combo box and the report therefore, effectively ignore this parameter, i.e. produce a report for a selected year but showing stats for all categories of course. How would I do it? TIA Martin Watts |
#4
|
|||
|
|||
The method that I prefer is to not set the criteria in the query. Write code
that builds a Where clause to use in the DoCmd.OpenReport method: Dim strWhere as String strWhere = "1 = 1 " If Not IsNull(Me.cboCategories) Then 'assuming the field is a text field strWhere = strWhere & " AND [CategoryField] = """ & me.cboCategories & """" 'if categoryField is numeric then uncomment the next line 'strWhere = strWhere & " AND [CategoryField] = " & me.cboCategories End If DoCmd.OpenReport "rptYourReport", acPreview, , strWhere -- Duane Hookom MS Access MVP "Ken Snell [MVP]" wrote in message ... Assuming that your query has a parameter similar to this: Forms!FormName!ComboBoxName Just replace it with this (assuming that the combo box is blank when you want all records): Forms!FormName!ComboBoxName Or Forms!FormName!ComboBoxName Is Null -- Ken Snell MS ACCESS MVP "Martin Watts" wrote in message ... I have a database holding details of students and training courses. One of the reports produces stats for selected years and selected category of courses, the year and category being set as parameters in the underlying query. The parameters are selected by the user from a combo box on a form. What I would like to do is give the user the option of selecting 'All Categories' in the combo box and the report therefore, effectively ignore this parameter, i.e. produce a report for a selected year but showing stats for all categories of course. How would I do it? TIA Martin Watts |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Passing query parameters in to a Report | johnb | Running & Setting Up Queries | 1 | January 10th, 2005 03:58 PM |
show parameters passed from vb app on access report | ranimath | Setting Up & Running Reports | 3 | October 29th, 2004 03:35 AM |
Display query parameters on report | Little pete | Setting Up & Running Reports | 4 | October 1st, 2004 02:01 PM |
Display Parameter from Form on Report | sara | Setting Up & Running Reports | 10 | July 19th, 2004 04:54 PM |