Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Searching for strings in DB ACCESS with VB6

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
dkhader
Asked:
dkhader
1 Solution
 
AHawthCommented:
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
 
CleanupPingCommented:
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
 
DanRollinsCommented:
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now