hi everyone
I have a module for filtering subform bese on 4 Fields in onchange event and I cant use it to filtering Listbox . can anyone help please ?
Module Code :
Option Compare Database
Function Search(Expr As String, Domain As String, txt_search As String) As String
x = txt_search & " "
For i = 1 To Len(txt_search)
c = InStr(1, x, " ")
If c > 0 Then
y = Left(x, c - 1)
x = Right(x, Len(x) - c)
i = c
q = q & " and " & "((" & Domain & "." & Expr & ") like '*" & y & "*')"
Else
Exit For
End If
Next i
q = q & " and " & "((" & Domain & "." & Expr & ") like '*" & x & "*')"
Search = Right(q, Len(q) - 5)
Debug.Print x
End Function
Text4 code for filtering subform :
Private Sub Text4_Change()
On Error Resume Next
Me.Form_sub.Form.Filter = Search("[Fname] & [Contry] & [Age] & [Phon]", "Table1", Nz(Me.Text4.Text))
Me.Form_sub.Form.FilterOn = True
Me.Form_sub.Form.Requery
If Me.Text4.Text = "" Then
Me.Form_sub.Form.FilterOn = False
Me.Form_sub.Form.Requery
End If
End Sub
Text4 code for filtering Listbox ???
I have a module for filtering subform bese on 4 Fields in onchange event and I cant use it to filtering Listbox . can anyone help please ?
Module Code :
Option Compare Database
Function Search(Expr As String, Domain As String, txt_search As String) As String
x = txt_search & " "
For i = 1 To Len(txt_search)
c = InStr(1, x, " ")
If c > 0 Then
y = Left(x, c - 1)
x = Right(x, Len(x) - c)
i = c
q = q & " and " & "((" & Domain & "." & Expr & ") like '*" & y & "*')"
Else
Exit For
End If
Next i
q = q & " and " & "((" & Domain & "." & Expr & ") like '*" & x & "*')"
Search = Right(q, Len(q) - 5)
Debug.Print x
End Function
Text4 code for filtering subform :
Private Sub Text4_Change()
On Error Resume Next
Me.Form_sub.Form.Filter = Search("[Fname] & [Contry] & [Age] & [Phon]", "Table1", Nz(Me.Text4.Text))
Me.Form_sub.Form.FilterOn = True
Me.Form_sub.Form.Requery
If Me.Text4.Text = "" Then
Me.Form_sub.Form.FilterOn = False
Me.Form_sub.Form.Requery
End If
End Sub
Text4 code for filtering Listbox ???