Hello -
I have a form called f_ReportsDashbo ard with several dropdowns that I use to generate a string of criteria values for reports.
Using the code below, I can succesfully generate the strCriteria in a stand-alone procedure.
The strCriteria for the above code prints correctly in the Immediate window.
I would like to be able to call Sub ReportFilters() in the OnClick event of the buttons on f_ReportsDashbo ard so I can generate filtered reports.
I currently have the following code for the OnClick event of a button:
The strCriteria does not print in the Immediate window, so strCriteria is not being carried over to this procedure.
QUESTION:
How do I "save" the strCriteria from Sub ReportFilters() so that I can use it on my button codes?
Can I save strCriteria as a named filter somehow?
I can generate the string each time but I am hoping there is a more efficient way to do this.
Much appreciated, as always :)
Sandra
I have a form called f_ReportsDashbo ard with several dropdowns that I use to generate a string of criteria values for reports.
Using the code below, I can succesfully generate the strCriteria in a stand-alone procedure.
Code:
Private Sub ReportFilters() ' Generate the String that will filter the reports Dim strCriteria As String First Field If IsNull(Me.RecStatus_DD.Value) Then strCriteria = strCriteria & " AND [RecordStatus] Like '*'" Else strCriteria = strCriteria & " AND [RecordStatus] ='" & Me.RecStatus_DD.Value & "'" End If ' ' several more additions to the strCriteria here .... ' 'Last Field If IsNull(Me.Approver_DD.Value) Then strCriteria = strCriteria & " AND [ApproverName] Like '*'" Else strCriteria = strCriteria & " AND [ApproverName] ='" & Me.Approver_DD.Value & "'" End If Debug.Print strCriteria End Sub
I would like to be able to call Sub ReportFilters() in the OnClick event of the buttons on f_ReportsDashbo ard so I can generate filtered reports.
I currently have the following code for the OnClick event of a button:
Code:
Private Sub Report_ByPriority_Btn_Click() Call ReportFilters Debug.Print [B]strCriteria[/B] DoCmd.OpenReport "r_MyReport", acViewPreview, , [B]strCriteria[/B], acWindowNormal End Sub
QUESTION:
How do I "save" the strCriteria from Sub ReportFilters() so that I can use it on my button codes?
Can I save strCriteria as a named filter somehow?
I can generate the string each time but I am hoping there is a more efficient way to do this.
Much appreciated, as always :)
Sandra
Comment