Access) (Form.AllowAdditions 属性

使用 AllowAdditions 属性指定用户在使用窗体时是否可以添加记录。 读/写 Boolean。

语法

表达式。AllowAdditions

expression:表示 Form 对象的变量。

备注

将 允许添加 属性设置为否以允许用户查看或编辑已有记录,但不是添加新的记录。

如果希望防止更改现有记录 (使窗体成为只读的), 允许添加 、 允许删除 ,和 允许编辑 属性设置为 no。 通过 记录集类型 属性设置为快照,还可以进行只读记录。

如果您想要打开的窗体的数据输入,将窗体的属性 设 为是。

当 允许添加 属性设置为否时,则在 记录 菜单上的 数据输入 命令不可用。

注意

使用 OpenForm 操作的 DataMode 参数时,Microsoft Access 将覆盖许多窗体属性设置。 如果 OpenForm 操作的 DataMode 参数设置为“编辑”,Access 将使用以下属性设置打开窗体:

  • AllowEdits - 是
  • AllowDeletions - 是
  • AllowAdditions - 是
  • DataEntry - 否

示例

下面的示例检查在窗体上所有控件的 ControlType 属性。 对于每个标签和文本框控件,该过程切换为这些控件的 特殊效果 属性。 当标签控件的 SpecialEffect 属性设置为 Shadowed,文本框控件的 SpecialEffect 属性设置为 Normal,并且 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

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。