使用 AllowAdditions 属性可以指定用户是否可在使用窗体时添加记录。Boolean 型,可读写。
expression.AllowAdditions
expression 必需。返回“Applies To”列表中的一个对象的表达式。
AllowAdditions 属性使用以下设置:
| 设置 | Visual Basic | 说明 | 
|---|---|---|
| 是 | True | (默认值)用户可以添加记录。 | 
| 否 | False | 用户不能添加记录。 | 
可以使用窗体属性表、宏或 Visual Basic 来设置 AllowAdditions 属性。
AllowAdditions 属性设置为“否”时,用户可以查看或编辑已有的记录,但不能添加记录。
如果要禁止更改已有记录(使窗体只读),可以将 AllowAdditions、AllowDeletions 和 AllowEdits 属性设置为“否”。也可以将 RecordsetType 属性设置为“快照”,使记录成为只读。
如果打开窗体只是为了输入数据,可以将窗体的 DataEntry 属性设置为“是”。
当 AllowAdditions 属性设置为“否”时,“记录”菜单上的“数据输入”命令将失效。
注意 当使用 OpenForm 操作的“数据模式”参数时,Microsoft Access 可能忽略某些窗体属性的设置。如果 OpenForm 操作的“数据模式”参数设置为“编辑”,Microsoft Access 将按以下属性设置打开窗体:
要防止 OpenForm 操作忽略任何现有的属性设置,可以省略“数据模式”参数,使 Microsoft Access 使用窗体定义的属性设置。
下面的示例检查窗体上所有控件的 ControlType 属性,并切换每个标签控件和文本框控件的 SpecialEffect 属性。当标签控件的 SpecialEffect 属性设置为“阴影”,文本框控件的 SpecialEffect 属性设置为“常规”,AllowAdditions、AllowDeletions 和 AllowEdits 属性设置为 True 时,intCanEdit 变量将切换到允许编辑基础数据的状态。 
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 = IFalse 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