100 likes | 223 Views
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
E N D
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.
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 & “’”
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.
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.
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.
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)
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.
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.
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
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.