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.