SQL code to search for a database item using only the first few letters a user inputs. Good for app
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
Rate SQL code to search for a database item using only the first few letters a user inputs. Good for app
(1(1 Vote))
'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
SQL code to search for a database item using only the first few letters a user inputs. Good for app Comments
No comments yet — be the first to post one!
Post a Comment