Search code examples
ms-accessselectionsubform

Filtered Query in Access Form


I have a form with a subform in it. There is a combo box in the header that is called cboBU that actively filters the subform query after each selection. My question is, when I load the form there is no data in the subform, this is because I have no selection in cboBU, how do I get the subform to show all results unless a cboBU selection occur


Solution

  • Create filter programmatically

    Sample:

    Private Sub cmdFilter_Click()
    
    SubFormCtlName.Form.Filter = "idCity=" & cboCity.Value & " AND " _
    "idCountry=" & cboCountry.Value
    SubFormCtlName.Form.FilterOn = True
    
    End Sub