Applies To Form.
Description
You can use the AllowAdditions property to specify whether a user can add a record when using a form.
Setting
The AllowAdditions property uses the following settings.
Setting | Description | Visual Basic |
Yes | (Default) The user can add new records. | True –1) |
No | The user can't add new records. | False (0) |
See Also AllowDeletions property, AllowEdits property, DataEntry property, OpenForm action, OpenForm method, RecordsetType property.
Example 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, AllowDeletions, and AllowEdits properties are all set to True, the intCanEdit 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
With ctl
Select Case .ControlType
Case acLabel
If .SpecialEffect = acEffectShadow Then
.SpecialEffect = acEffectNormal
.BorderStyle = conTransparent
intCanEdit = True
Else
.SpecialEffect = acEffectShadow
intCanEdit = False
End If
Case acTextBox
If .SpecialEffect = acEffectNormal Then
.SpecialEffect = acEffectSunken
.BackColor = conWhite
Else
.SpecialEffect = acEffectNormal
.BackColor = frm.Detail.BackColor
End If
End Select
End With
Next ctl
If intCanEdit = False Then
With frm
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
End With
Else
With frm
.AllowAdditions = True
.AllowDeletions = True
.AllowEdits = True
End With
End If
End Sub