1 / 10

Find Methods

Find Methods. Each of the Find methods begins its search from the location and in the direction specified as the following. Find method Begins searching at Search direction FindFirst Beginning of recordset to End of recordset FindLast End of recordset to Beginning of recordset

jamal
Download Presentation

Find Methods

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Find Methods • Each of the Find methods begins its search from the location and in the direction specified as the following. • Find method Begins searching at Search direction • FindFirst Beginning of recordset to End of recordset • FindLast End of recordset to Beginning of recordset • FindNext Current record to End of recordset • FindPrevious Current record to Beginning of recordset • Using one of the Find methods isn't the same as using a Move method, which simply makes the first, last, next, or previous record current without specifying a condition.

  2. Recordset.FindPrevious Method • Locates the previous record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record • Syntax:expression.FindPrevious(Criteria) • expression A variable that represents a Recordset object. • rstEmployees.FindFirst “name = " & “ ’ ” • & txtname.text & “’”

  3. Recordset.FindNext Method • Locates the next record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). . • Syntax:expression.FindNext(Criteria) • expression A variable that represents a Recordset object.

  4. Recordset.FindLast Method • Locates the last record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). • Syntax:expression.FindLast(Criteria) • expression A variable that represents a Recordset object.

  5. Recordset.FindFirst Method • Locates the first record in a dynaset- or snapshot-type Recordset object that satisfies the specified criteria and makes that record the current record (Microsoft Access workspaces only). • Syntax:expression.FindFirst(Criteria) • expression : A variable that represents a Recordset object.

  6. Recordset.Seek Method • Locates the record in an indexed table-type Recordset object that satisfies the specified criteria for the current index and makes that record the current record (Microsoft Access workspaces only). • Syntax:expression.Seek(Comparison, Key1)

  7. Seek contd. • Comparison Required String One of the following string expressions: <, <=, =, >=, or >. • Key1, Key2...Key13 represents One or more values corresponding to fields in the Recordset object's current index, as specified by its Index property setting. You can use up to 13 key arguments.

  8. Seek contd • You must set the current index with the Index property before you use Seek. • If the index identifies a nonunique key field, Seek locates the first record that satisfies the criteria. • The Seek method searches through the specified key fields and locates the first record that satisfies the criteria specified by comparison and key1. • Once found, it makes that record current and sets the NoMatch property to False. • If the Seek method fails to locate a match, the NoMatch property is set to True, and the current record is undefined.

  9. Seek contd • If comparison is equal (=), greater than or equal (>=), or greater than (>), Seek starts at the beginning of the index and searches forward. • If comparison is less than (<) or less than or equal (<=), Seek starts at the end of the index and searches backward. • However, if there are duplicate index entries at the end of the index, Seek starts at an arbitrary entry among the duplicates and then searches backward. • STRID = InputBox("ENTER ID TO SEARCH") • rs.Index = "PRODID" • rs.Seek "=", Val(STRID) • Call ASSIGN • If rs.NoMatch Then • MsgBox ("NO RECORDS FOUND WITH " & STRID & "PRODUCT ID") • End If

  10. Constraints • You can't use the Seek method on a linked table because you can't open linked tables as table-type Recordset objects. • However, if you use the OpenDatabase method to directly open an installable ISAM (non-ODBC) database, you can use Seek on tables(recordsets) in that database.

More Related