Using a filter on a subform
I am trying to use a filter on a subform. I have a combo box on the main form.
If I selected a name in the combo box and click the search button, I want the matching data to appear in the substring.
If I set the source of the row in the combo box as SELECT [table].[name] FROM table
, the values ββare not displayed in the combo box, but I get the desired data in the subform using the following code.
Private Sub SearchName_Click()
If IsNull(Me.ComboName.Value) Then
Me.SubList.Visible = False
MsgBox "Please select nameγ", vbOKOnly + vbCritical
Else
Me.SubList.Visible = True
Call frm_Enter
End If End Sub
Private Sub frm_Enter()
Dim CustName As String
CustName = Me.ComboName.Value
With Me.SubList.Form
.Filter = "[name]='" & CustName & "'"
.FilterOn = True
End With
End Sub
If I change the source of the row in the combo box to SELECT [table].[Id], [table].[name] FROM table
, the values ββin the combo box are displayed, but I don't get the desired result in the subform.
I tried changing the filter to .Filter = "[Id]='" & CustName & "'"
, but the result didn't change. Any suggestion is greatly appreciated.
source to share