I have a form called "Search Issues' and a Subform within call "Browse All Issues". Browse All Issues Record source is a table that contains all the data called Issues. I'm trying to create search features within "Search Issues" where I can select multiple criteria from List box and when I click Search Browse all issues filter on the criteria I selected. I currently I the following code:
Private Sub Search_Click()
On erorr GoTo errr
Me.Search.Form.RecordSource = "SELECT * From Browse_All_IssuesSubform " & BuildFilter
Me.Search.Form.Requery
Exit Sub
errr:
MsgBox Err.Description
End Sub
Private Function BuildFilter() As Variant
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
BuildFilter = strWhere
End Function
How can I get his to work? When I run the event I get the message "Compile Error" : Method or data member not found.
Please help
On erorr GoTo errr
, tryOn Error
instead. ;) – The Blue Dog