I'm trying to use filter on sub form. I have a combo box on the main form.
If Name is selected in the combo box and hit search button I want the respective data to be displayed in the sub form.
If I set the row source of the combo box as SELECT [table].[name] FROM table
, the values are not displayed in the combo box but I get desired data in subform using 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 row source of the combo box to SELECT [table].[Id], [table].[name] FROM table
, the values in combo box are displayed but I don't get the desired result in the sub form.
I tried changing the filter to .Filter = "[Id]='" & CustName & "'"
, but there was no change in the result.
Any suggestion is very much appreciated.