Setting Criteria for reports

  • Thread starter Thread starter Michael Hanlon
  • Start date Start date
M

Michael Hanlon

I have a report that runs off a query that show 16 course and i need to be
able to set the criteria during runtime on only the course the user has
choose from the course selection form.

So if I was to choose cisco from the comb box1 and completed from comb box2.
I will need the report to show just the people that completed the cisco
course. On the query for Cisco i need to setup a criteria to read completed
but if i run the same form again and choose access and completed i will need
to have the report show this. Any help thanks
 
I use code similar to the following:
Dim strWhere as String
strWhere = "1=1 "
If Not IsNull(Me.cboCourse) Then
strWhere = strWhere & " AND [Course] = '" & Me.cboCourse & "' "
End If
If Not IsNull(Me.cboStatus) Then
strWhere = strWhere & " AND [Status] ='" & Me.cboStatus & "' "
End If
DoCmd.OpenReport "rptYourReport", acPreview, , strWhere

This code made lots of assumptions and recommendations regarding your object
names and data types.
 
Back
Top