You can use the AllowEdits property to specify whether a user can edit saved records when using a form (form: An Access database object on which you place controls for taking actions or for entering, displaying, and editing data in fields.). Read/write Boolean.
expression Required. An expression that returns one of the objects in the Applies To list.
The AllowEdits property uses the following settings.
||(Default) The user can edit saved records.
||The user can't edit saved records.
You can set the AllowEdits property by using the form's property sheet (property sheet: A pane that is used to view or modify the properties of various objects such as tables, queries, fields, forms, reports, data access pages, and controls.), a macro (macro: An action or set of actions that you can use to automate tasks.), or Visual Basic for Applications (VBA) (Visual Basic for Applications (VBA): A macro-language version of Microsoft Visual Basic that is used to program Microsoft Windows-based applications and is included with several Microsoft programs.) code.
You can use the AllowEdits property to prevent changes to existing data displayed by a form. If you want to prevent changes to data in a specific control, use the Enabled or Locked property.
If you want to prevent changes to existing records (make a form read-only), set the AllowAdditions, AllowDeletions, and AllowEdits properties to No. You can also make records read-only by setting the RecordsetType property to Snapshot.
Changing a field value programmatically causes the current record to be editable, regardless of the AllowEdits property setting. If you want to prevent the user from making changes to a record (AllowEdits is No) that you need to edit programmatically, save the record after any programmatic changes; the AllowEdits property setting will be honored once again after any unsaved changes to the current record are saved.
Note When the Data Mode argument of the OpenForm action is set, Microsoft Office Access 2007 will override a number of form property settings. If the Data Mode argument of the OpenForm action is set to Edit, Access will open the form with the following property settings:
- AllowEdits — Yes
- AllowDeletions — Yes
- AllowAdditions — Yes
- DataEntry — No
To prevent the OpenForm action from overriding any of these existing property settings, omit the Data Mode argument setting so that Access will use the property settings defined by the form.
The following example examines the ControlType
property for all controls on a form. For each label and text box control, the procedure toggles the SpecialEffect
property for those controls. When the label controls' SpecialEffect
property is set to Shadowed
and the text box controls' SpecialEffect
property is set to Normal
and the AllowAdditions
, and AllowEdits
properties are all set to True
variable is toggled to allow editing of the underlying data.
Sub ToggleControl(frm As Form)
Dim ctl As Control
Dim intI As Integer, intCanEdit As Integer
Const conTransparent = 0
Const conWhite = 16777215
For Each ctl in frm.Controls
Select Case .ControlType
If .SpecialEffect = acEffectShadow Then
.SpecialEffect = acEffectNormal
.BorderStyle = conTransparent
intCanEdit = True
.SpecialEffect = acEffectShadow
intCanEdit = False
If .SpecialEffect = acEffectNormal Then
.SpecialEffect = acEffectSunken
.BackColor = conWhite
.SpecialEffect = acEffectNormal
.BackColor = frm.Detail.BackColor
If intCanEdit = IFalse Then
.AllowAdditions = False
.AllowDeletions = False
. = False
.AllowAdditions = True
.AllowDeletions = True
. = True