P
PJ
I have had alot of great help using this forum so far and needed a
little help with some code I found and am currently using. I am using a
combo box that filters a subform shown as a datasheet. Everything works
great I just need to know how to set it to turn the filter off if the
combo box is either blank or if I add an "All" entry to the combo box.
All or null = show all, or turn the filter off. Thanks in advance.
Private Sub Combo0_AfterUpdate()
' Declare variables
Dim frm As Form
Dim strInput As Variant
Dim strFilter As String
' Store value selected in combo box by user
strInput = [Combo0]
' This is the line of code that refers to the subform from the main
form:
Set frm = Forms![testinvwithsub]![InvTbltestform].Form
' Build criteria string
strFilter = BuildCriteria("Building", dbText, strInput)
' Set Filter property to apply filter
frm.Filter = strFilter
' Set FilterOn property to show filtered records
frm.FilterOn = True
End Sub
I wanted to say thanks to Tina, she helped me greatly with buttons to
print out the filtered data.
little help with some code I found and am currently using. I am using a
combo box that filters a subform shown as a datasheet. Everything works
great I just need to know how to set it to turn the filter off if the
combo box is either blank or if I add an "All" entry to the combo box.
All or null = show all, or turn the filter off. Thanks in advance.
Private Sub Combo0_AfterUpdate()
' Declare variables
Dim frm As Form
Dim strInput As Variant
Dim strFilter As String
' Store value selected in combo box by user
strInput = [Combo0]
' This is the line of code that refers to the subform from the main
form:
Set frm = Forms![testinvwithsub]![InvTbltestform].Form
' Build criteria string
strFilter = BuildCriteria("Building", dbText, strInput)
' Set Filter property to apply filter
frm.Filter = strFilter
' Set FilterOn property to show filtered records
frm.FilterOn = True
End Sub
I wanted to say thanks to Tina, she helped me greatly with buttons to
print out the filtered data.