Article ID: 113903
Article Last Modified on 1/8/2003
If no matching records are found, the NoMatch property is TRUE and the current record remains the same as before the Find method was used.
NOTE: Always inspect the value of the NoMatch property of the recordset to determine whether the SEEK method has succeeded. If it fails, NoMatch is TRUE and the current record is unchanged"
Sub Command1_Click ()
Const DB_LANG_GENERAL = ";LANGID=0x0809;CP=1252;COUNTRY=0"
Const DB_DOUBLE = 7
Const DB_TEXT = 10
Dim db As Database
Dim tb As table
Set db = CreateDatabase(App.Path + "\NUMBERS.MDB", DB_LANG_GENERAL)
Dim td As New tabledef
Dim F1 As New field
Dim F2 As New field
td.Name = "Amounts"
F1.Name = "Desc"
F1.Type = DB_TEXT
F1.Size = 35
td.Fields.Append F1
F2.Name = "Num1"
F2.Type = DB_DOUBLE
td.Fields.Append F2
db.TableDefs.Append td
Dim TempIndex As New Index
TempIndex.Name = "test"
TempIndex.Fields = "num1"
db.TableDefs("Amounts").Indexes.Append TempIndex
Set tb = db.OpenTable("Amounts")
For I = 0 To 10
tb.AddNew
tb.Fields("Desc") = "hello" & I
tb.Fields("Num1") = CDbl(I * 10)
tb.Update
Next I
tb.Close
db.Close
End Sub
Sub Command2_Click ()
On Error GoTo eh
Dim db As Database
Dim tb As table
Set db = OpenDatabase(App.Path + "\NUMBERS.MDB")
Set tb = db.OpenTable("Amounts")
Print "====Test of Seek Method===="
tb.Index = "test"
tb.MoveFirst
Print "MoveFirst Values= "; tb(0); tb(1)
tb.Seek "=", 50 ' Finds valid record.
Print "Seek = 50 NoMatch="; tb.NoMatch; " Values= "; tb(0); tb(1)
Print
tb.MoveNext
Print "MoveNext Values= "; tb(0); tb(1)
tb.Seek "=", 500 ' Doesn't find valid record.
Print "Seek = 500 NoMatch="; tb.NoMatch; " Values= "; tb(0); tb(1)
tb.Close
db.Close
Exit Sub
eh:
Print
Print "*** Error Occurred displaying Current Record ***"
Print
Resume Next
End Sub
Sub Command3_Click ()
Dim db As Database
Dim ds As Dynaset ' OR Dim ds As snapshot
Set db = OpenDatabase(App.Path + "\NUMBERS.MDB")
Set ds = db.CreateDynaset("Amounts")
' OR Set ds = db.CreateSnapshot("Amounts")
Print "====Test of FindFirst Method===="
ds.MoveFirst
Print "MoveFirst Values= "; ds(0); ds("Num1")
ds.FindFirst "num1 = 50"
' Enter the following two lines as one, single line:
Print "FindFirst 50 NoMatch="; ds.NoMatch; " Values= ";
ds(0); ds("Num1")
Print
ds.MoveNext
Print "MoveNext Values= "; ds(0); ds("Num1")
ds.FindFirst "num1 = 500"
' Enter the following two lines as one, single line:
Print "FindFirst 500 NoMatch="; ds.NoMatch; " Values= ";
ds(0); ds("Num1")
Print
ds.Close
db.Close
End Sub
Additional query words: 3.00 docerr
Keywords: KB113903