Form.AllowAdditions 屬性 (Access)

使用 AllowAdditions 屬性來指定使用者在使用表單時是否可以新增記錄。 可讀寫的 Boolean。

語法

運算式。AllowAdditions

expression 代表 Form 物件的變數。

註解

設定 AllowAdditions 屬性為 [否] 以允許使用者檢視或編輯現有的記錄,但不是新增記錄。

若要防止變更現有的記錄 (使表單唯讀),設定 AllowAdditions 、 AllowDeletions 、 和 AllowEdits 屬性設為 no。 您也可以讓記錄唯讀 RecordsetType 屬性設定為快照。

若要開啟僅供資料輸入表單,將表單的 DataEntry 屬性設定為 [是]。

當 AllowAdditions 屬性設定為 [否] 時、 [ 記錄 ] 功能表上的 [ 資料輸入 ] 命令無法使用。

注意事項

當使用 OpenForm 巨集指令的 DataMode 引數時,Microsoft Access 會覆寫許多表單屬性設定。 如果 OpenForm 巨集指令的 DataMode 引數設為 [編輯],Access 會使用下列屬性設定開啟表單:

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

範例

下列範例會檢查 ControlType 屬性在表單上的所有控制項。 每個標籤和文字] 方塊中控制項的程序會切換這些控制項的 SpecialEffect 屬性。 當標籤控制項的 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 支援與意見反應。