by capp00 (8 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 29th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
SQL code to search for a database item using only the first few letters a user inputs. Good for applications where users could misspell the
'amounts of text.
'this way, users can type a little bit of information,
'such as the first few letters, and it will search the
'database for the first matching item and move to that
'recordset.
'Created and Tested in VB6 by Andy P.
Private Sub Command1_Click()
Dim strName As String, strTarget As String
strName = text1.text 'sets text in a textbox to a string
'searches for first record matching the string entered above
strTarget = "(field name) LIKE " & "'*" & strName & "*'" 'wildcard search
datWhatever.Recordset.FindFirst strTarget 'moves to first match
If datWhatever.Recordset.NoMatch Then 'if not found then
MsgBox "No records found", , "None Found" 'no records found
Exit Sub
End If
End Sub
No comments have been posted about SQL code to search for a database item using only the first few letters a user inputs. Good for app. Why not be the first to post a comment about SQL code to search for a database item using only the first few letters a user inputs. Good for app.