* To make a reference to DAO in Visual Basic
Dim DB As Database CommonDialog1.ShowOpen Set DB = OpenDatabase(CommonDialog1.filename) If Not DB Is Nothing Then MsgBox "Successfully connected!" Else MsgBox "Could not connect." End If
When you connect to the database, you will get a message box displaying the connection status.
The Recordset Object
The Recordset object defines a group of records so they can be manipulated or viewed . A Recordset object represents the records in a base table or the records that result from running a query. While a recordset can contain many records, only one record can be the current record.
Example
This example opens a recordset in Visual Basic:Dim db As Database Dim rs As Recordset ' Open the Northwind database Set db = OpenDatabase("Northwind.mdb") ' Open a recordset Set rs = db.OpenRecordset("SELECT * FROM Employees", _ dbOpenDynaset, dbReadOnly) ' Add code here to process the records . . . ' When finished close the objects rs.Close db.Close