ACC: Cannot Change RecordsetType Property in Form View

Last reviewed: August 29, 1997
Article 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.

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:

          Public Function ChangeRecordsetType()
    
             Const conSnapshot = 2
             DoCmd.OpenForm "Employees", acDesign
             Forms!Employees.RecordsetType = conSnapshot
             DoCmd.OpenForm "Employees", acNormal
          End Function
    
    

  3. 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:

          Sub Form_Open(Cancel As Integer)
             Const conSnapshot = 2
             Forms!Employees.RecordsetType = conSnapshot
          End Sub
    
    

  4. Save and close the Employees form.

  5. 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.
Keywords          : DcmHlp FmsProp
Version           : 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbdocerr


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.