NoMatch Property Example

This example adds all the names of customers for the state of Washington to a list on worksheet one. The data is drawn from the Customer recordset in the Nwindex.mdb database.

To create the Nwindex.mdb database, run the Microsoft Excel example for the CreateDatabase method.

Dim db As Database, rs As Recordset
rw = 0
Set db = Workspaces(0).OpenDatabase(Application _
    .DefaultFilePath & "\NWINDEX.MDB")
Set rs = db.OpenRecordset("SELECT * FROM Customer")
criteria = "[REGION] = 'WA'"
Set wk = Worksheets.Add
rs.FindFirst criteria
Do Until rs.NoMatch
    rw = rw + 1
    wk.Cells(rw, 1).Value = rs.Fields("COMPANY").Value
    rs.FindNext criteria
Loop
rs.Close
db.Close