As Usual, When creating the form with Options and values on it (Combo-Boxes, Text-Boxes Based on a table)
has it's Navigation bar with Nav Buttons and "Search" function... I disabled Navigation Buttons, because i did myself with my design and customization (Working Perfectly - No problems), but I need that search function which was gone with navigation buttons..
How to create the same search on my own with text-box or something else (I call it instant search) Because it's searching very smartly.... and is very "Must Have" Option..
I'm Using The Code: It is not working as instant but very handy Search.....
Put a textbox in the form header. Name it txtSearch. Add a button named cmdSearch. Select the button in design view and press F7 to take you to the button's click event.
Change "CompanyName" to whatever your field name is. As long as it is a text field it should work.
Put this code in the Sub
Private Sub cmdSearch_Click()
Dim bkmk As Variant
Dim strField As String
Me.RecordsetClone.MoveFirst
'Find the first record that matches what
'is in the search text box.
Me.RecordsetClone.FindFirst "CompanyName Like " _
& Chr(34) & Me.txtSearch & "*" & Chr(34)
If Me.RecordsetClone.NoMatch Then
MsgBox "No Match"
Else
bkmk = Me.RecordsetClone.Bookmark
Me.Recordset.Bookmark = bkmk
End If
End Sub
how to add many fields (for example if i have 10 fields: field1, field2, field3, field4 etc) that the code could search in all fields not only specified..
Thank You Very Much
has it's Navigation bar with Nav Buttons and "Search" function... I disabled Navigation Buttons, because i did myself with my design and customization (Working Perfectly - No problems), but I need that search function which was gone with navigation buttons..
How to create the same search on my own with text-box or something else (I call it instant search) Because it's searching very smartly.... and is very "Must Have" Option..
I'm Using The Code: It is not working as instant but very handy Search.....
Put a textbox in the form header. Name it txtSearch. Add a button named cmdSearch. Select the button in design view and press F7 to take you to the button's click event.
Change "CompanyName" to whatever your field name is. As long as it is a text field it should work.
Put this code in the Sub
Private Sub cmdSearch_Click()
Dim bkmk As Variant
Dim strField As String
Me.RecordsetClone.MoveFirst
'Find the first record that matches what
'is in the search text box.
Me.RecordsetClone.FindFirst "CompanyName Like " _
& Chr(34) & Me.txtSearch & "*" & Chr(34)
If Me.RecordsetClone.NoMatch Then
MsgBox "No Match"
Else
bkmk = Me.RecordsetClone.Bookmark
Me.Recordset.Bookmark = bkmk
End If
End Sub
how to add many fields (for example if i have 10 fields: field1, field2, field3, field4 etc) that the code could search in all fields not only specified..
Thank You Very Much