Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











METHOD:  Recordset::Find

recordsetobject.Find  Criteria, SkipRecords, SearchDirection, Start

The Find method is used to search a Recordset for a Record that matches the search criteria (a search string). This method will work if the Recordset supports bookmarks. If the search is successful, the current record pointer will be moved to point to the first Record that matches. If the search fails, the Recordset will point to either EOF or BOF.

There is one mandatory and three optional parameters.

The mandatory Criteria parameter is a string that defines the search criteria. This string must contain one field (column) name, one comparison operator, and a search value.

You can only search on one field (column).

The comparison operators in Criteria can only be one of the following:

  =   >   >=   <   <=   <>   LIKE

You cannot use OR or AND.

The value in Criteria can be a date, number, or string. If the value is a string, it must be enclosed (delimited) within a pair of single quotes ("State = ' Tennessee' ") or a pair of pound signs ("State = #Tennessee# "). If the value is a date, it must be enclosed (delimited) within a pair of pound signs ("Birthdate = #6/26/1943# "). Numbers are not delimited ("Age = 104").

If you are using the LIKE operator, you can also use the asterisk * wildcard either after the value in Criteria or before and after the value in Criteria ( "LastName LIKE ' * stein * ' " or "State = ' T * ' ). Some providers also support using the % and _ wildcards.

The optional SkipRecords parameter is a long value that specifies how many records beyond the current record to skip to before starting the search. The default is zero which means that the search starts at the current record.

The optional SearchDirection parameter is one of the SearchDirectionEnum constants that specify which direction the search should proceed, either forward or backward. If no matching record is found for a forward search, the record pointer is set at EOF. If no matching record is found for a backward search, the record pointer is set at BOF.

SearchDirectionEnum Constants
 
Constant Value Description
adSearchBackward -1 Searches from the designated starting point backward to the first record
adSearchForward 1 Searches from the designated starting point forward to the last record

 
The optional Start parameter is a variant that is either a bookmark or one of the BookmarkEnum constants that indicates the starting position for the search. The default is to start at the current record.

BookmarkEnum Constants
 
Constant Value Description
adBookmarkCurrent 0 Default, start search at current record
adBookmarkFirst 1 Start search at first record
adBookmarkLast 2 Start search at last record

 
Code (VBScript):
varBookMark = rsChantList.Bookmark
rsChantList.MoveFirst
rsChantList.Find "ChantName = 'Oma' "
If (rsChantList.BOF = True) OR (rsChantList.EOF = True) Then
   MsgBox "Record not found"
   rsChantList.Bookmark = varBookMark
End If

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information