hi,
I have trouble filtering data in the subform. There are 4 combo boxes in the main form named "CATDATA" and the subform's name is "sfrProjectList". I have a Filter command button named cmdFilter in the main Form. Upon clicking the button, the data in the subform should be filtered based on any combination selection of values from the 4 combos. The problem is my code doesnt work at all. Perhaps could you write me a source code for the cmdFilter command button? Thanks so much.. Below are the code for cmdFilter that i used and it doesn't work. The data from the subform sftProjectList are obtain from the "ProjectList" table
Private Sub cmdFilter_Click()
Dim strFilter As String
If Len(Me.cboFilterStatus & vbNullString) > 0 Then
strFilter = "ProjectList.StatusID=" & Me.cboFilterStatus.Value
End If
If Len(Me.cboFilterAccuracy.V
alue & vbNullString) > 0 Then
If Len(strFilter) > 0 Then
strFilter = strFilter & " AND "
End If
strFilter = strFilter & "ProjectList.AccuracyID='"
& Me.cboFilterAccuracy.Value
& "'"
End If
If Len(Me.cboFilterDepartment
.Value & vbNullString) > 0 Then
If Len(strFilter) > 0 Then
strFilter = strFilter & " AND "
End If
strFilter = strFilter & "ProjectList.DepartmentID=
'" & Me.cboFilterDepartment.Val
ue & "'"
End If
If Len(Me.cboFilterARPOther.V
alue & vbNullString) > 0 Then
If Len(strFilter) > 0 Then
strFilter = strFilter & " AND "
End If
strFilter = strFilter & "ProjectList.ARPOther='" & Me.cboFilterARPOther.Value
& "'"
End If
If Len(strFilter) > 0 Then
Me.sfrProjectList.Form.Fil
ter = strFilter
Me.sfrProjectList.Form.Fil
terOn = True
Me.sfrProjectList.Form.Req
uery
Else
Me.sfrProjectList.Form.Fil
terOn = False
End If
End Sub
Start Free Trial