Filter Report Using Form

joepineapples

Registered User.
Local time
Today, 08:11
Joined
Apr 28, 2006
Messages
29
Hi All

I have a macro that I use to open a report using a filter from a form. On the form I have a combo box called cboQuarter.

In my macro I add the following to my where condition:

[Forms]![frmReports]![cboQuarter]=[qryOutputVariance]![Quarter]

This works fine and what I get is a filtered report that shows all my records that match the quarter picked in the combo box.

What I would like to do is add a further criteria.

I have another combo box called cbocriteria which has the values '>', '=' and '<' in it.

what I would like to do is create the filter where:

My report is filtered by the quarter as defined by the criteria e.g. cboQuarter([Forms]![frmReports]![cboQuarter]) > reportQuarter ([qryOutputVariance]![Quarter])

I hope this makes sense - as my request seems a little convoluted.
 
Filter Report Using Form - solved

I had to change my method - rather than running a macro I used vba code instead.

I had a form with three combo boxes:

cboQuarter that contained the values 1 - 4.
cboQuarterCriteria that contained the values =, >,<
cboMonitoring - this was populated with a table containing all the report names.

My code was as follows:
Code:
Private Sub RunReport_Click()

Dim QuarterCalculation As String
' Filter by Quarter criteria

If CheckQuarter.Value = True Then
            
        QuarterCalculation = cboQuarterCriteria & " " & cboQuarter
        DoCmd.OpenReport cboMonitoring, acViewPreview, , "Quarter" & QuarterCalculation & ""
        
End If

End Sub

So, you select a quarter, a criteria and a report from the comboboxes e.g. Quarter 1, Criteria > and Report 'OutstandingTasks'. And it will open the OutstandingTasks report where the quarter is greater than 1.

There's a little bit more to do - but this solves my initial query.

Regards

JP:)
 

Users who are viewing this thread

Back
Top Bottom