Discussion Locked

searching in ACCESS DB tables?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How the search engines work , and is there any algorithm ,and how can i apply it on database that containing alot of long text fields using MS ACCESS 2000?

5 replies

by bowjangles

If you are trying to search for a particular record in a table here are two ways to do it.

1) You must open a Recordset:
Dim found As Boolean
Dim dbs As Database, rst As Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("TABLE_NAME", dbOpenDynaset)

found = True

Do Until rst.Fields("FIELD_NAME") = VARIABLE_NAME
rst.MoveNext
If rst.EOF Then
found = False
Exit Do
End If
Loop

At the end...If Found = True you have found the record and the current record is the one you are looking for.

2)if you have a table called tblEmployees, you could open your recordset like...

set rst = currentdb.openrecordset("tblEmployees", dbopendynaset)

Now, if your table has say 10 records, you could search for one specific record by using the .Findfirst method of the recordset.

To use the .Findfirst, you must search for values inside the columns or fields inside the table. For example if tblEmployees has 3 fields named, EmpID, EmpFirst, EmpLast, you do a search on those fields.

the syntax is as follows...

rst.Findfirst criteria

criteria is a string variable with a SEARCH string inside of it.

So you would code something asfollows...
'******
dim strCriteria as string
'dim you recordset, whatever

strCriteria = "EmpFirst = 'BLAH' AND EmpLast = 'BLAHBLAH'"

rst.Findfirst strCriteria
'*******

The recordset will then search for a record with the values 'BLAH' and 'BLAHBLAH'. If it finds it, good, if not, too bad. There is a way to check if your FindFirst returned a record or not...

if rst.noMatch = true then
'you didn't find a match
else
'you did find a match
end if

by spankil

Hi Nawaf0,

If you are talking about the Internet Search Engine this may work on Text Search i.e a Page Containing text Searched. Most of the Seach engine uses Meta Tag of HTML Page to Search a Text, Some of them uses entire page search.

But in your case you wants to search Entire word or a Text inside field in a Particular field.
If you want to Search Entire word then the above answer will work fine. but if you want to Search a Text inside word then you have to use wild-car Chars like '*' or '%' in a query

Suppose u want to find a text Called 'XYZ' in 'Hello this is XYZ' then

you can find it by

Select * from TableName where FieldName like '%XYZ%'

This will find the above word

If you are working on large data base then I suggest that you give index on that field.

Hope this will help you.

This discussion is closed to new replies.