Sub cmdOpenRecordset_Click()
    ' Declare and instantiate the object variables
    Dim cnStateUBookstore As Connection
    Dim rsStudents As Recordset
    Set cnStateUBookstore = New Connection
    Set rsStudents = New Recordset

    ' Establish a connection
    With cnStateUBookstore
        .Provider = "SQLOLEDB"
        .ConnectionString = "User ID=sa;" & _
                            "Data Source=MSERIES1;" & _
                            "Initial Catalog=StateUBookstore"
        .Open
    End With

    ' Open a recordset using the Connection object variable
    rsStudents.Open "SELECT StudentID FROM Students", cnStateUBookstore
End Sub