O'Reilly logo

Microsoft® Access Projects with Microsoft SQL Server™ by Natascha Nicol, Ralf Albrecht

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Accessing the Data by Recordset

DAO and ADO use recordsets to access the data itself. In DAO, use the following commands:

Dim db As DAO.Database
Dim rec As DAO.Recordset
 
Set db = CurrentDB
Set rec = db.OpenRecordset("SELECT * FROM tblFilms", dbOpenDynaset)

The following is the ADO variant:

Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
 
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM tblFilms", _
		ActiveConnection:=cnn, _
		CursorType:=adOpenStatic, _
		LockType:=adLockOptimistic

Table 17-2 compares the parameters that you can specify for opening a recordset.

Table 17-2. Comparison of Recordset Types
DAO ADO
dbOpenDynaset CursorType = adOpenStatic, LockType = adLockOptimistic CursorType = adOpenDynamic ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required