Delete this code:
Code:
Private Sub cmbLanguage_Click()
Me.Filter = "Languages Like 'E*'"
Me.FilterOn = True
End Sub
I was giving you an example of code to filter a form. If you have the combo box on the main form and you want to filter a sub-form, you would have to change the code in the combo box after update event to refer to the sub form.
So, if the name of the combo box is "cmbLanguage", and the name of the sub form is "Subform1", then the code would be:
Code:
Option Compare Database ' these two lines should be at the top of every module
Option Explicit ' these two lines should be at the top of every module
Private Sub cmbLanguage_AfterUpdate()
'sets a filter
If Me.cmbLanguage = "E" Then
'All English
Me!Subform1.Form.Filter = "[Languages] Like 'E*'"
Me!Subform1.Form.FilterOn = True
ElseIf Me.cmbLanguage = "F" Then
'All French
Me!Subform1.Form.Filter = "[Languages] Like 'F*'"
Me!Subform1.Form.FilterOn = True
ElseIf Me.cmbLanguage = "EF" Then
' Bilingual
Me!Subform1.Form.Filter = "[Languages] Like 'EF'"
Me!Subform1.Form.FilterOn = True
End If
End Sub
Private Sub btnClearFilter_Click()
Me.Filter = ""
Me.FilterOn = False
End Sub
See attached mdb.