1. Open a recordset with as recordsource an SQL statement like this :
Select * from CLIENTS where CLIENT_Name like "Smith*".
The asterisk after Smith will return also the records where the name BEGINS
2. Do a loop on the recordset :
While rs.eof = false then
do something with the record
You can use also a SQL statement to specify the recordsource of a
THIS IS THE HELP FILE TEXT FROM VB4 :
Expression Like "pattern"
The Like operator syntax has these parts:
expression SQL expression used in a WHERE clause.
pattern String or character string literal against which expression is
You can use the Like operator to find values in a field that match the
pattern you specify. For pattern, you can specify the complete value (for
example, Like "Smith"), or you can use wildcard characters like those
recognized by the operating system to find a range of values (for example,
In an expression, you can use the Like operator to compare a field value to
a string expression. For example, if you enter Like "C*" in an SQL query,
the query returns all field values beginning with the letter C. In a
parameter query, you can prompt the user for a pattern to search for.
The following example returns data that begins with the letter P followed
by any letter between A and F and three digits:
In Visual Basic, if expression matches pattern, result is True (-1); if
there is no match, result is False (0); and if either expression or pattern
is a Null, result is also a Null.
THIS IS AN EXAMPLE FROM THE VB4 DOC
This example returns a list of employees whose names begin with the letters
A through D.
SELECT * FROM Employees WHERE LastName Like "[A-D]*"
Hope this helps.
Visit the Visual Basic Central!
a database field for a particular wordQuote:> I have battled with a problem for almost 4 months now. I need to search
using the search string of "Smith". IQuote:> within the field...
> Example, I need to search a clients name field (Smith, John, E.) buy
and move the record pointer to the firstQuote:> want the program to search for the first occurance of the word "Smith"
have to type the full name of theQuote:> occurence.
> Right now, I am using FINDFIRST to locate a clients record. However, I
using the "INSTR" with the FINDFIRST butQuote:> client (Smith, John, E.) in order to locate the record. I have tried
scaned the newsgroups, AOL and all the VBQuote:> I can not get the program to work.
> I know there is a way to search for a string within a field! I have
Quote:> books I own. Could someone PLEASE tell me how to search for a string?
> Aaron J. Pommier
> Harvey & Stuckel, Chtd.