Access.2007.VBA.Bibl..

(John Hannent) #1
& vbCrLf & vbTab & “City: “ & ![City] _
& vbCrLf
rst.MoveNext
Loop
End With

ErrorHandlerExit:

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 If

If Not cnn Is Nothing Then
If cnn.State = adStateOpen Then
cnn.Close
Set cnn = Nothing
End If
End If

Exit Sub

ErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit
End Sub

The following information is printed to the Immediate window:


2 records in recordset

Australian Company name: G’day, Mate
Contact name: Wendy Mackenzie
City: Sydney

Australian Company name: Pavlova, Ltd.
Contact name: Ian Devling
City: Melbourne

Forward-only

The forward-only cursor (DAO equivalent: dbOpenForwardOnly) allows only forward move-
ment through a recordset and doesn’t show additions, changes, or deletions made by other users.


Working with Access Data 5

Free download pdf