?
Solved

Searching for strings in DB ACCESS with VB6

Posted on 2003-02-19
3
Medium Priority
?
268 Views
Last Modified: 2010-05-01
hi,

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

0
Comment
Question by:dkhader
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Accepted Solution

by:
AHawth earned 200 total points
ID: 7985502
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.
0
 

Expert Comment

by:CleanupPing
ID: 8901422
dkhader:
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?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8959703
Moderator, my recommended disposition is:

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

DanRollins -- EE database cleanup volunteer
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question