1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| Option Compare Database
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer
' Build SQL String.
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
' strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 5))
' Set the Filter property
Reports![RptBy2].Filter = strSQL
Reports![RptBy2].FilterOn = True
Else
Reports![RptBy2].FilterOn = False
End If
End Sub
Private Sub Clear_Click()
Dim intCounter As Integer
For intCounter = 1 To 5
Me("Filter" & intCounter) = ""
Next
End Sub
Private Sub Close_Click()
DoCmd.Close acForm, Me.Form.Name
End Sub
Private Sub Form_Close()
DoCmd.Close acReport, "RptBy2" 'Close the BY report.
DoCmd.Restore 'Restore the window size
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenReport "RptBy2", A_PREVIEW 'Open BY report.
DoCmd.Maximize 'Maximize the report window
End Sub |