Hi,
I have below code for maximum 3 criteria dynamic search:
There is a problem, since I put the code in a textbox's on change event. then in case i want to revise the first two criteria, the cursor will automatically fleets to the end of the text, I want to know how to keep the position of the cursor?
Thanks
I have below code for maximum 3 criteria dynamic search:
Code:
Private Sub SearchFor_Change()
Dim strWhere As String
Dim Criteria As String
Dim i As Integer
Dim A
Dim strAdd As String
On Error Resume Next
strAdd = Me.SearchFor.Text
Me.SearchFor.Value = strAdd
Criteria = "[Materials_Name] & [Materials_Specification]"
i = (Len(Me.SearchFor) - Len(Replace(Me.SearchFor, ";", ""))) / Len(";")
Select Case i
Case 0
strWhere = Criteria & "Like '*" & strAdd & "*'"
Case 1
A = Split(Me.SearchFor.Text, ";")
strWhere = Criteria & "Like '*" & A(0) & "*' And" & Criteria & "Like '*" & A(1) & "*'"
Case 2
A = Split(Me.SearchFor.Text, ";")
strWhere = Criteria & "Like '*" & A(0) & "*' And" & Criteria & "Like '*" & A(1) & "*' And" & Criteria & "Like '*" & A(2) & "*'"
End Select
Me.SearchFor.SetFocus
Me.SearchFor.SelStart = Me.SearchFor.SelLength
Me.Materials_Records_Inner.Form.Filter = strWhere
Me.Materials_Records_Inner.Form.FilterOn = True
Call Count_Materials_No
End Sub
There is a problem, since I put the code in a textbox's on change event. then in case i want to revise the first two criteria, the cursor will automatically fleets to the end of the text, I want to know how to keep the position of the cursor?
Thanks