Find record by using Recordset.FindFirst : Recordset Find « Access « VBA / Excel / Access / Word

Home
VBA / Excel / Access / Word
1.Access
2.Application
3.Data Type
4.Data Type Functions
5.Date Functions
6.Excel
7.File Path
8.Forms
9.Language Basics
10.Math Functions
11.Outlook
12.PowerPoint
13.String Functions
14.Windows API
15.Word
16.XML
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VBA / Excel / Access / Word » Access » Recordset Find 
Find record by using Recordset.FindFirst
 
Sub findrecorder()
    Dim dbNorthwind As DAO.Database
    Dim dbPath As String
    DbPath = CurrentProject.Path & "mydb.mdb"
    Set dbNorthwind = OpenDatabase(dbPath)
    
    Dim rsEmployees As DAO.Recordset
    Dim rsCustomers As DAO.Recordset
    Set rsEmployees = dbNorthwind.OpenRecordset("Employees", dbOpenTable)
    Set rsCustomers = dbNorthwind.OpenRecordset("Customers", dbOpenTable)
    rsCustomers.MoveLast
    numCustomers = rsCustomers.RecordCount
    With rsEmployees
        .FindFirst "City = 'Seattle'"
        If .NoMatch Then
            MsgBox ("No Records Found!")
            .MoveFirst
        Else
            MsgBox ("Found "& .Fields(2).Value & " "& .Fields(1).Value & _
                 "in Seattle")
        End If
    End With
End Sub

 
Related examples in the same category
1.Finding the Record Position
2.Change column data case
3.Simple Select statement
4.SQL with where clause
5.Select specific column in select statement
6.Finding Records Using the Find Method
7.Finding a Record Based on Multiple Criteria
8.Finding a Specific Record in a Recordset
9.NoMatch property in Recordset
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.