A
Ali
Hello, I've been using this example to filter a subform using multiple
combo boxes on the main form
http://www.tonyhine.co.uk/photogallery/Downloads/CboBoxesFilterResults_ALLorSome.zip
The only difference with mine is that I use a set filter button where
as the example has the code in the combo box.
Here's the code for the query for the subform, the main form has all
the combo boxes with the set filter button:
SELECT issues.ID, issues.Status, issues.[Assigned To],
IIf([ID],"ViewEdit","") AS ViewEdit, issues.[Opened By],
issues.Project, issues.Category, issues.Priority, issues.Department,
issues.Title
FROM issues
WHERE (((issues.ID) Like fCboSearch([Forms]![Main]![ID])) AND
((issues.Status) Like fCboSearch([Forms]![Main]![Status])) AND
((issues.[Assigned To]) Like fCboSearch([Forms]![Main]![AssignedTo]))
AND ((issues.[Opened By]) Like fCboSearch([Forms]![Main]![OpenedBy]))
AND ((issues.Project) Like fCboSearch([Forms]![Main]![Project])) AND
((issues.Category) Like fCboSearch([Forms]![Main]![Category])) AND
((issues.Priority) Like fCboSearch([Forms]![Main]![Priority])) AND
((issues.Department) Like fCboSearch([Forms]![Main]![Department])) AND
((issues.Title) Like fCboSearch([Forms]![Main]![Text_search])))
ORDER BY issues.Status;
This is the code for the module:
Public Function fCboSearch(vCboSearch As Variant)
If IsNull(vCboSearch) Or vCboSearch = "" Then
fCboSearch = "*"
Else
fCboSearch = vCboSearch
End If
End Function
And this is what happens when I click Set Filter
Private Sub Search_Click()
fSetVar
End Sub
Private Sub fSetVar()
issueqrysubform.Requery
End Sub
Now what I need help with is that I need to be able to do a text
search from the main form using an unbound text box and then clicking
the set filter button to do the search. Also using the same set filter
button I want to be able to search for records using data ranges. I
have all the textboxes setup for the calendar dates, I just can't
understand the coding behind it to do the actual search.
Thanks.
combo boxes on the main form
http://www.tonyhine.co.uk/photogallery/Downloads/CboBoxesFilterResults_ALLorSome.zip
The only difference with mine is that I use a set filter button where
as the example has the code in the combo box.
Here's the code for the query for the subform, the main form has all
the combo boxes with the set filter button:
SELECT issues.ID, issues.Status, issues.[Assigned To],
IIf([ID],"ViewEdit","") AS ViewEdit, issues.[Opened By],
issues.Project, issues.Category, issues.Priority, issues.Department,
issues.Title
FROM issues
WHERE (((issues.ID) Like fCboSearch([Forms]![Main]![ID])) AND
((issues.Status) Like fCboSearch([Forms]![Main]![Status])) AND
((issues.[Assigned To]) Like fCboSearch([Forms]![Main]![AssignedTo]))
AND ((issues.[Opened By]) Like fCboSearch([Forms]![Main]![OpenedBy]))
AND ((issues.Project) Like fCboSearch([Forms]![Main]![Project])) AND
((issues.Category) Like fCboSearch([Forms]![Main]![Category])) AND
((issues.Priority) Like fCboSearch([Forms]![Main]![Priority])) AND
((issues.Department) Like fCboSearch([Forms]![Main]![Department])) AND
((issues.Title) Like fCboSearch([Forms]![Main]![Text_search])))
ORDER BY issues.Status;
This is the code for the module:
Public Function fCboSearch(vCboSearch As Variant)
If IsNull(vCboSearch) Or vCboSearch = "" Then
fCboSearch = "*"
Else
fCboSearch = vCboSearch
End If
End Function
And this is what happens when I click Set Filter
Private Sub Search_Click()
fSetVar
End Sub
Private Sub fSetVar()
issueqrysubform.Requery
End Sub
Now what I need help with is that I need to be able to do a text
search from the main form using an unbound text box and then clicking
the set filter button to do the search. Also using the same set filter
button I want to be able to search for records using data ranges. I
have all the textboxes setup for the calendar dates, I just can't
understand the coding behind it to do the actual search.
Thanks.