O'Reilly logo

F. Scott Barker's Microsoft® Access 2000 Power Programming by F. Scott Barker

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

CREATING A RECORDSET WITH ADO

Now it's time to see how to use ADO to perform one of the most common tasks—opening recordsets.

Opening a Simple Recordset

To open a recordset, you will first create a connection object off the current project, and then specify a new ADO recordset object:

Sub OpenRecordsetWithGetStringDisplayExample()

        Dim cnnLocal     As New ADODB.Connection
        Dim rstCurr     As New ADODB.Recordset

        Set cnnLocal = CurrentProject.Connection

        rstCurr.Open "Select * from tblMovieTitles where ReleaseDate _
                                    = #02/01/99#", cnnLocal, _
                                    adOpenStatic, adOpenPessimistic

        Debug.Print rstCurr.GetString

        rstCurr.Close

End Sub

Although this code is very similar to DAO, in ADO you use the Recordset object's Open method rather than an OpenRecordset method. ...

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