Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21111

Advanced search engine

$
0
0
Im trying to make an access database search engine, but im trying to do some trick on it.

ok, let me try to explain my issue as clear as possible.

1st: typing the item you what to search on a textbox
Code:

Private Sub txtScan_Change()
search
End Sub

2nd on textbox change will trigger the syntax for matching the input on the database with 'like' statement
Code:

Sub search()
Set rs = New ADODB.Recordset
rs.Open "Select * from tblMainAssets where Assettag like'" & txtScan.Text & "%';", cn, adOpenKeyset, adLockOptimistic
form1.searchthelist
End Sub

3rd and last is to populate the listview with the matching records based on step 1 and 2 so it will only show records that matched with textbox
Code:

Sub searchthelist()
'On Error Resume Next
If Not rs.EOF Then
ListView1.ListItems.Clear
rs.MoveFirst
Do While Not rs.EOF
Set Item = ListView1.ListItems.Add(, , rs!assettag)
Item.SubItems(1) = rs!assetdescription
Item.SubItems(2) = rs!SIte
Item.SubItems(3) = rs!Building
Item.SubItems(4) = rs!Location
Item.SubItems(5) = rs!Floor
Item.SubItems(6) = rs!Remarks
Item.SubItems(7) = rs!LabelStatus
rs.MoveNext
Loop
Else
ListView1.ListItems.Clear
End If
rs.Close
Set rs = Nothing
End Sub


this is my current way of searching the database, its pretty useful and accurate, as it will show you the records that will match with the one you typed on the textbox and populate a listview with all the matching records. The problem is, if the user would like to use more filtering on searching. Let's say I will try to search

Model: BMW
Color: Black
Year:2012
Model: X5

if I will try to search for 'BMW' keyword alone, it will try to show all BMW cars, then to norrow the search I will type the model, then the year and so on. Does anyone have an idea on how to do it?

THANKS FOR READING :)

Viewing all articles
Browse latest Browse all 21111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>