Hello All:
I have the below VBA in a from for it to filter the records below based on the criteria:
Private Sub Search_Click()
Dim strWhere As String
strWhere = IIf(Len(Me.AssignedTo & "") <> 0, "([AssignedTo] Like ""*" & Me.AssignedTo & "*"") AND", "") & _
IIf(Len(Me.OpenedBy & "") <> 0, "([OpenedBy] Like ""*" & Me.OpenedBy & "*"") AND", "") & _
IIf(Len(Me.Status & "") <> 0, "([Status] Like ""*" & Me.Status & "*"") AND", "") & _
IIf(Len(Me.Category & "") <> 0, "([Category] Like ""*" & Me.Category & "*"") AND", "") & _
IIf(Len(Me.Priority & "") <> 0, "([Priority] Like ""*" & Me.Priority & "*"") AND", "") & _
IIf(Len(Me.OpenedDateFrom & "") <> 0, "([EnteredOn] >= #" & Format(Me.OpenedDateFrom, "mm/dd/yyyy") & "#) AND", "") & _
IIf(Len(Me.DueDateFrom & "") <> 0, "([EnteredOn] <= #" & Format(Me.DueDateFrom, "mm/dd/yyyy") & "#) AND", "")
If Len(strWhere & "") = 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
Me.Filter = Left(strWhere, Len(strWhere & "") - 4)
Me.FilterOn = True
Me.Requery
End If
End Sub
When I click the search button nothing happens, is there something wrong with my code??
I have the below VBA in a from for it to filter the records below based on the criteria:
Private Sub Search_Click()
Dim strWhere As String
strWhere = IIf(Len(Me.AssignedTo & "") <> 0, "([AssignedTo] Like ""*" & Me.AssignedTo & "*"") AND", "") & _
IIf(Len(Me.OpenedBy & "") <> 0, "([OpenedBy] Like ""*" & Me.OpenedBy & "*"") AND", "") & _
IIf(Len(Me.Status & "") <> 0, "([Status] Like ""*" & Me.Status & "*"") AND", "") & _
IIf(Len(Me.Category & "") <> 0, "([Category] Like ""*" & Me.Category & "*"") AND", "") & _
IIf(Len(Me.Priority & "") <> 0, "([Priority] Like ""*" & Me.Priority & "*"") AND", "") & _
IIf(Len(Me.OpenedDateFrom & "") <> 0, "([EnteredOn] >= #" & Format(Me.OpenedDateFrom, "mm/dd/yyyy") & "#) AND", "") & _
IIf(Len(Me.DueDateFrom & "") <> 0, "([EnteredOn] <= #" & Format(Me.DueDateFrom, "mm/dd/yyyy") & "#) AND", "")
If Len(strWhere & "") = 0 Then
MsgBox "No criteria", vbInformation, "Nothing to do."
Else
Me.Filter = Left(strWhere, Len(strWhere & "") - 4)
Me.FilterOn = True
Me.Requery
End If
End Sub
When I click the search button nothing happens, is there something wrong with my code??