Microsoft KB Archive/164095

= ACC: Cannot Change RecordsetType Property in Form View =

Article ID: 164095

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q164095



SYMPTOMS
Moderate: Requires basic macro, coding, and interoperability skills.

The example in the RecordsetType property Help topic implies that you can set the RecordsetType property of a form in the Open event of the form. The example states:

In the following example, only if the user ID is ADMIN can records be updated. This code sample sets the RecordsetType property to Snapshot if the public variable gstrUserIDD value is not ADMIN. Sub Form_Open(Cancel As Integer) Const conSnapshot = 2 If gstrUserID <> "ADMIN" Then Forms!Employees.RecordsetType = conSnapshot End If  End Sub This example is incorrect. You can set the RecordsetType property of the form; however, the property has no effect.

NOTE: This behavior no longer occurs in Microsoft Access 2000.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.



RESOLUTION
Set the RecordsetType property of a form by opening the form in Design view, changing the property, and then opening the form in Form view.

Changing the RecordsetType of a Form
 Start Microsoft Access and open the sample database Northwind.mdb.  Create a module and type the following procedure: Public Function ChangeRecordsetType Const conSnapshot = 2 DoCmd.OpenForm "Employees", acDesign Forms!Employees.RecordsetType = conSnapshot DoCmd.OpenForm "Employees", acNormal End Function   To test this function, type the following line in the Debug window, and then press ENTER: ?ChangeRecordsetType Try to edit records on the open Employees form. Note that you cannot. 



Steps to Reproduce Behavior
CAUTION: Following the steps in this example will modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and perform these steps on a copy of the database.  Start Microsoft Access and open the sample database Northwind.mdb. Open the Employees form in Design view.</li>  Set the OnOpen property of the form to the following event procedure: Sub Form_Open(Cancel As Integer) Const conSnapshot = 2 Forms!Employees.RecordsetType = conSnapshot End Sub </li> Save and close the Employees form.</li> Open the Employees form in Form view. Note that you can still edit records in the form even though the RecordsetType property is set to Snapshot.</li></ol>

Keywords: kbprogramming KB164095

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.