Form.RecordsetType property (Access)
Use the RecordsetType property to specify what kind of recordset is made available to a form. Read/write Byte.
Syntax
expression.RecordsetType
expression A variable that represents a Form object.
Remarks
The RecordsetType property uses the following settings in a Microsoft Access database.
Setting | Type of recordset | Description |
---|---|---|
0 | Dynaset | (Default) You can edit bound controls based on a single table or tables with a one-to-one relationship. For controls bound to fields based on tables with a one-to-many relationship, you can't edit data from the join field on the "one" side of the relationship unless cascade update is enabled between the tables. |
1 | Dynaset (Inconsistent Updates) | All tables and the controls bound to their fields can be edited. |
2 | Snapshot | No tables or the controls bound to their fields can be edited. |
Note
If you don't want data in bound controls to be edited when a form is in Form view or Datasheet view, you can set the RecordsetType property to 2.
Note
Changing the RecordsetType property of an open form or report causes an automatic recreation of the recordset.
You can create forms based on multiple underlying tables with fields bound to controls on the forms. Depending on the RecordsetType property setting, you can limit which of these bound controls can be edited.
In addition to the editing control provided by RecordsetType, each control on a form has a Locked property that you can set to specify whether the control and its underlying data can be edited. If the Locked property is set to Yes, you can't edit the data.
Property value
UINT8
Example
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 gstrUserID 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
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for