Hello,
I’m using the following code to filter subform in main form, my subform source object is based on query, and there are some columns of the subform has relationship with another table, as you see in the below code it’s related to district table, and I’m using lookup to display district name, but in my vendor table it stores DistrictID which is a number. My problem is that below code is working with if I typed the DistrictID as number but not working if typed district name.
Any suggestion support please.
Regards
Private Sub txtKeyWord_Change()
' If there is no filter criteria, disable filtering '
If Len(Trim(txtKeyWord.Text)) = 0 Then
DS.Form.FilterOn = False
Exit Sub
End If
Dim strFilterDS As String
strFilterDS = "[VendorName] LIKE '*" & Trim$(txtKeyWord.Text) & "*'" _
& " or [District_FK] LIKE '*" & Trim$(txtKeyWord.Text) & "*' "
DS.Form.Filter = strFilterDS
DS.Form.FilterOn = True
End Sub
I’m using the following code to filter subform in main form, my subform source object is based on query, and there are some columns of the subform has relationship with another table, as you see in the below code it’s related to district table, and I’m using lookup to display district name, but in my vendor table it stores DistrictID which is a number. My problem is that below code is working with if I typed the DistrictID as number but not working if typed district name.
Any suggestion support please.
Regards
Private Sub txtKeyWord_Change()
' If there is no filter criteria, disable filtering '
If Len(Trim(txtKeyWord.Text)) = 0 Then
DS.Form.FilterOn = False
Exit Sub
End If
Dim strFilterDS As String
strFilterDS = "[VendorName] LIKE '*" & Trim$(txtKeyWord.Text) & "*'" _
& " or [District_FK] LIKE '*" & Trim$(txtKeyWord.Text) & "*' "
DS.Form.Filter = strFilterDS
DS.Form.FilterOn = True
End Sub