I am looking to develop a form that shows records in a report based upon criteria defined in said form. So far I have had success in filtering city names, state, and whether or not the client is a medicaid recipient. Unfortunately, my knowledge does not include how to search a range, such as "Find all records where the age of the client is between 20 and 25" Do I need to define 2 variables and than tell the filter to find all numbers in between those two numbers? What is the most expedient path? Here is what I have so far:
Code:
Private Sub cmdApplyFilter_Click()
Dim strCity As String
Dim strState As String
Dim strFilter As String
Dim strMedicaid As String
'Define Option Group
Select Case Me.fraMedicaid.Value
Case 1
strMedicaid = "='Y'"
Case 2
strMedicaid = "='N'"
Case 3
strMedicaid = "Like '*'"
End Select
'Define ComboBoxes and Filter
If IsNull(Me!cboCity.Value) Then
strCity = "Like '*'"
Else: strCity = "='" & Me!cboCity.Value & "'"
End If
If IsNull(Me!cboState.Value) Then
strState = "Like '*'"
Else: strState = "='" & Me!cboState.Value & "'"
End If
strFilter = "[ChildCity] " & strCity & " AND [StateAbb] " & strState & " AND [CurrMedicaid] " & strMedicaid
'Turn on Filter
With Reports![rptMain]
.Filter = strFilter
.FilterOn = True
End With
End Sub
Private Sub cmdRemoveFilter_Click()
On Error Resume Next
Reports![rptMain].FilterOn = False
End Sub