R
rupertsland
I'd like to filter a subform from a main form using VBA. I've set up a combo
box control and written code to store the value selected in the combo box. I
am having trouble writing the code such that it will filter the subform. Can
anyone help?
The following is the code I used. It does not filter the subform, but
instead it calls up another form and applies the filter to this form. This
works fine. Can this code be modified to filter a subform? If so, what code
should I use and where?
Dim frm As Form
Dim strInput As Variant
Dim strFilter As String
strInput = [ComboBox_Project] ' store value selected by user in combo
box
DoCmd.OpenForm "frm_Reports_Datasheet", acFormDS ' open form
Set frm = Forms!frm_Reports_Datasheet
' Build criteria string
strFilter = BuildCriteria("PROJ_NAME", dbText, strInput)
' Set Filter property to apply filter
frm.Filter = strFilter
' Set FilterOn property to show filtered records
frm.FilterOn = True
box control and written code to store the value selected in the combo box. I
am having trouble writing the code such that it will filter the subform. Can
anyone help?
The following is the code I used. It does not filter the subform, but
instead it calls up another form and applies the filter to this form. This
works fine. Can this code be modified to filter a subform? If so, what code
should I use and where?
Dim frm As Form
Dim strInput As Variant
Dim strFilter As String
strInput = [ComboBox_Project] ' store value selected by user in combo
box
DoCmd.OpenForm "frm_Reports_Datasheet", acFormDS ' open form
Set frm = Forms!frm_Reports_Datasheet
' Build criteria string
strFilter = BuildCriteria("PROJ_NAME", dbText, strInput)
' Set Filter property to apply filter
frm.Filter = strFilter
' Set FilterOn property to show filtered records
frm.FilterOn = True