Mega Code Archive

 
Categories / VisualBasic Script / Access
 

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