I want to apply a filter using a search button which i applied the folowung codes:
# Sub Search()Dim strCriteria, task As String
If Trim(Me.cboIncomeType.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Please select Payment mode.", buttons:=vbInformation, title:="SOFTWARE"
Me.cboIncomeType.SetFocus
Exit Sub
End If
If Trim(Me.cboIncomeType1.Value & vbNullString) = vbNullString Then
MsgBox prompt:="Please select Payment form.", buttons:=vbInformation, title:="SOFTWARE"
Me.cboIncomeType1.SetFocus
Exit Sub
End If
If IsNull(Me.OrderDateFrom) Then
MsgBox "Please enter the Start date", vbInformation, "Date Range Required"
Me.OrderDateFrom.SetFocus
Else
If IsNull(Me.OrderDateTo) Then
MsgBox "Please enter the End date", vbInformation, "End Date Required"
Me.OrderDateTo.SetFocus
Else
strCriteria = "[DATE] >= " & Format(Me.OrderDateFrom, "\#mm\/dd\/yyyy\#") & _
" And [DATE] <= " & Format(Me.OrderDateTo, "\#mm\/dd\/yyyy\#") & _
" And[PAYMENT_FORM] LIKE '" & IIf(IsNull(Me.cboIncomeType1), "*", Me.cboIncomeType1) & _
" And[PAYMENT_MODE] LIKE '" & IIf(IsNull(Me.cboIncomeType), "*", Me.cboIncomeType) & "'"
'task = "select * from PAY_FORM_ALL_EXPENSE where (" & strCriteria & ") order by [DATE]" ) #
I initially thought my filter took effect but later realized the "DoCmd.ApplyFilter , strCriteria" was not applying the filter.
Any help to fix this will be highly appreciated.