Searching for strings in DB ACCESS with VB6


how can i check if a special text given in an text-field exists in ACCESS database ?

how can i write this in VB6 ?

Thanx in Advans

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If I understand you question correctly, you want to search the records for one that contains the specified criteria. There's 2 ways to do this easily:

1. Use the Jet "Find" functions. This will work if the recordset is of a dynaset or snapshot type. In this example, SearchCriteria is a string variable and dynasetname is the name of the recordset. The first record that matches will become the current record.

SearchCriteria= "FieldName = Criteria"
dynasetname.findfirst SearchCriteria

If dynasetname.nomatch= true then a match was not found.

*Note: This example assumes that the recordset is already open. If using a table recordset, you must use the Seek command.

2. Use an SQL statement to open a recordset containing only the records that match.

Set dynasetname=databasename.openrecordset("SELECT * from TABLENAME where FIELDNAME = 'CRITERIA'", dbopendynaset)

You can also use the 'LIKE' keyword in place of the '=' to locate records using wildcard characters (*criteria*).

Hope that helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
Moderator, my recommended disposition is:

    Accept AHawth's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.