G
Guest
I have a search Form using the following code:
___________________________________
Private Sub SearchClick_Click()
Dim strSql As String
strSql = "select * from items where Description Like '" &
Me.SearchText.Value & "*'"
Me.sbfrmItemsSearch.Form.RecordSource = strSql
Me.sbfrmItemsSearch.Requery
End Sub
___________________________________
It works, however not exactly how I need it to.
The 'Description' column that it is comparing to the user search criteria
(Me.SearchText.Value) is more like a sentence describing an item name (i.e.
"Software Transmittal for I&P: Build Structure 12.05").
With the current search 'Like', it will compare the 'Me.SearchText.Value' to
the first terms in the 'Description' column (i.e. 'Software').
However, let's say a user were to enter "Build Structure" for the search
criteria. This search code would fail to return anything that didn't start
with "Build Structure", even though the 'Description' column of the item does
contain "Build Structure" within the text "Software Transmittal for I&P:
Build Structure 12.05".
Anotherwords, the search above does a "Starts with..." search instead of a
"Contains..." search.
Is there a way to alter it to make it a "Contains..." search?
Thanks for your help in advance.
___________________________________
Private Sub SearchClick_Click()
Dim strSql As String
strSql = "select * from items where Description Like '" &
Me.SearchText.Value & "*'"
Me.sbfrmItemsSearch.Form.RecordSource = strSql
Me.sbfrmItemsSearch.Requery
End Sub
___________________________________
It works, however not exactly how I need it to.
The 'Description' column that it is comparing to the user search criteria
(Me.SearchText.Value) is more like a sentence describing an item name (i.e.
"Software Transmittal for I&P: Build Structure 12.05").
With the current search 'Like', it will compare the 'Me.SearchText.Value' to
the first terms in the 'Description' column (i.e. 'Software').
However, let's say a user were to enter "Build Structure" for the search
criteria. This search code would fail to return anything that didn't start
with "Build Structure", even though the 'Description' column of the item does
contain "Build Structure" within the text "Software Transmittal for I&P:
Build Structure 12.05".
Anotherwords, the search above does a "Starts with..." search instead of a
"Contains..." search.
Is there a way to alter it to make it a "Contains..." search?
Thanks for your help in advance.