Filters on Reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have (3) diffrent reports that are driven by a field called
"ViolationsNumber". I want to be able to run a string to have the reports
open by using that field. Can I go into the reports and set a filter on them
to have each number equal a report. For example;

1-Violation Notice
<=2 And >=3 - WRANotice
<=4 PenaltyNotice

How can I get this to work?

Here is a string that I created to run the report but all it does is open
the ViolationNotice report for all.

Private Sub CitationReports_Click()

Dim stDocNameViolationNotice As String
Dim stDocNameWRANotice As String
Dim stDocNamePenaltyNotice As String

stDocNameViolationNotice = "ViolationNotice"
stDocNameWRANotice = "WRANotice"
stDocNamePenaltyNotice = "PenaltyNotice"

If Number <= 1 Then
DoCmd.OpenReport stDocNameViolationNotice, acPreview
End If

If Number = 2 Then
DoCmd.OpenReport stDocNameWRANotice, acPreview
End If

If Number = 3 Then
DoCmd.OpenReport stDocNameWRANotice, acPreview
End If

If Number >= 4 Then
DoCmd.OpenReport stDocNamePenaltyNotice, acPreview
End If

End Sub

Thanks,
 
Where does your code get the value for Number?
You might want to simplify your code like:

Private Sub CitationReports_Click()
Dim stDocName As String
Select Case Me.Number
Case Is <= 1
strDocName ="ViolationNotice"
Case 2, 3
strDocName = "WRANotice"
Case Is >= 4
strDocName = "PenaltyNotice"
Case Else
'could provide a default
End Select
If Len(strDocName)>0 Then
DoCmd.OpenReport stDocName, acPreview
Else
Msgbox "Select a number", vbOkOnly, "PEBKAC"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top