ACC: Cannot Change RecordsetType Property in Form View

ID: Q164095


The information in this article applies to:
  • Microsoft Access versions 7.0, 97


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

  1. Start Microsoft Access and open the sample database Northwind.mdb.


  2. Create a module and type the following procedure:


  3. 
          Public Function ChangeRecordsetType()
             Const conSnapshot = 2
             DoCmd.OpenForm "Employees", acDesign
             Forms!Employees.RecordsetType = conSnapshot
             DoCmd.OpenForm "Employees", acNormal
          End Function 
  4. 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.



MORE INFORMATION

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.
  1. Start Microsoft Access and open the sample database Northwind.mdb.


  2. Open the Employees form in Design view.


  3. Set the OnOpen property of the form to the following event procedure:


  4. 
          Sub Form_Open(Cancel As Integer)
             Const conSnapshot = 2
             Forms!Employees.RecordsetType = conSnapshot
          End Sub 
  5. Save and close the Employees form.


  6. 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.


Additional query words:

Keywords : AccCon FmsProp
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type :


Last Reviewed: November 5, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.