It is the default cursor type. For the fastest access to data that you don’t need to modify, use a
forward-only cursor and the adLockReadOnlylock type, as in the TestForwardReadOnly
procedure that follows; if you do need to modify the data, use the adLockOptimisticlock
type instead:Private Sub TestForwardReadOnly()On Error GoTo ErrorHandlerDim cnn As ADODB.Connection
Dim rst As ADODB.RecordsetCreate a connection to the current database.Set cnn = CurrentProject.Connection
Set rst = New ADODB.RecordsetCreate a recordset based on a select query.rst.Open Source:=”qryCompanyAddresses”, _
ActiveConnection:=cnn.ConnectionString, _
CursorType:=adOpenForwardOnly, _
LockType:=adLockReadOnlyIterate through the query, and print values from its fields to the Immediate window.Do While Not rst.EOF
Debug.Print “Company ID: “ & rst![CompanyID] _
& vbCrLf & vbTab & “Category: “ _
& rst![Category] _
& vbCrLf & vbTab & “Company Name: “ _
& rst![Company] & vbCrLf
rst.MoveNext
LoopErrorHandlerExit:Close the Recordset and Connection objects.If Not rst Is Nothing Then
If rst.State = adStateOpen Then
rst.Close
Set rst = Nothing
End If
End IfIf Not cnn Is Nothing Then
If cnn.State = adStateOpen Then
cnn.ClosePart II Writing VBA Code to Exchange Data between Office Components