'--- begin DAO ---
Dim db As DAO.Database, rs As DAO.Recordset
Set db=currentdb()
Set rs = db.openrecordset( "select * from mytable", dbOpenDynaset)
With rs
If Not .EOF Then
.MoveFirst
Do Until .EOF
Debug.Print !MyField
.Movenext
Loop
End If
.Close
End With
Set rs=nothing
Set db=nothing
'--- end DAO ---
'--- begin ADO ---
Dim cn As ADODB.Connection, rs As ADODB.Recordset
Set cn = Application.CurrentProject.Connection
Set rs = New ADODB.Recordset
With rs
rs.Open "MyTable", cn, adOpenDynamic, adLockOptimistic, adCmdText
If Not .EOF Then
.MoveFirst
Do Until .EOF
Debug.Print !MyField
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
Set db = Nothing
'--- end ADO ---
Copyright By AccessVision
|