Microsoft KB Archive/230737

= ACC2000: Cannot Set Form Recordset to Disconnected Recordset =

Article ID: 230737

Article Last Modified on 12/12/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q230737



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access project (.adp).



SYMPTOMS
When you try to assign an ActiveX Data Objects (ADO) Recordset object to a form, you may receive the following error message:

The object you entered is not a valid Recordset property.



CAUSE
You assigned a disconnected ADO Recordset object to the Recordset property of the form.



RESOLUTION
Set the ActiveConnection property of the ADO recordset to a valid ADO Connection object before assigning it to the form.



MORE INFORMATION
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 </li> Switch from the Visual Basic Editor to Microsoft Access.</li> Save the Customers form and close it.</li> 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.

</li></ol>

<div class="references_section">