ADO allows you to create a recordset, and then to disconnect it from its source. In a client/server environment, this allows you to update the recordset on the client without maintaining a constant connection to the server. Later, your changes are batch updated to the server. Even though ADO allows you to disconnect a recordset from its source and manipulate it on the client without a connection, Microsoft Access forms bound to
Recordset objects require a valid ADO
Connection object.
Steps to Reproduce Behavior
CAUTION: If you follow the steps in this example, you modify the sample Access project NorthwindCS.adp. You may want to back up the NorthwindCS.adp file and follow these steps on a copy of the project.
- Open the sample Access project NorthwindCS.adp.
- Open the Customers form in Design view.
- Clear the RecordSource property of the form so that the form is no longer bound.
- On the View menu, click Code.
- Add the following event procedure to the module of the form:
Private Sub Form_Open(Cancel As Integer)
Dim rs As ADODB.Recordset
'Create a new ADO recordset, and disconnect it
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Source = "SELECT * FROM Customers"
.Open
.ActiveConnection = Nothing
End With
Set Me.Recordset = rs
End Sub
- Switch from the Visual Basic Editor to Microsoft Access.
- Save the Customers form and close it.
- Open the Customers form in Form view from the Database window. Note that you receive the following error when setting the form Recordset property to the disconnected recordset:
The object you entered is not a valid Recordset property.