AllowDeletions 屬性

此頁沒有內(nèi)容條目
內(nèi)容

expandtri全部顯示

使用 AllowDeletions 屬性可以指定用戶是否可在使用窗體時刪除記錄。Boolean 型,可讀寫。

expression.AllowDeletions

expression     必需。返回“應(yīng)用于”列表中的一個對象的表達(dá)式。

設(shè)置

AllowDeletions 屬性使用以下設(shè)置:

設(shè)置

Visual Basic

說明

True

(默認(rèn)值)用戶可以刪除記錄。

False

用戶不能刪除記錄。

 

可以使用窗體屬性表Visual Basic 來設(shè)置 AllowDeletions 屬性。

說明

該屬性設(shè)置為“否”時,用戶可以查看和編輯已有的記錄,但不允許刪除記錄。當(dāng) AllowDeletions 屬性設(shè)置為“是”時,在不破壞現(xiàn)有參照完整性規(guī)則的條件下,可以刪除記錄。

如果要禁止更改已有記錄(使窗體只讀),可以將 AllowAdditionsAllowDeletionsAllowEdits 屬性設(shè)置為“否”。也可以將 RecordsetType 屬性設(shè)置為“快照”,使記錄成為只讀。

當(dāng) AllowDeletions 屬性設(shè)置為“否”時,“編輯”菜單上的“刪除記錄”命令將失效。

注釋  如果設(shè)置了 OpenForm 操作的“數(shù)據(jù)模式”參數(shù),Microsoft Access 將忽略許多窗體屬性設(shè)置。如果 OpenForm 操作的“數(shù)據(jù)模式”參數(shù)設(shè)置為“編輯”,Microsoft Access 所打開的窗體將具有下列屬性設(shè)置:

?AllowEdits:是

 

?AllowDeletions:是

 

?AllowAdditions:是

 

?DataEntry:否

要防止 OpenForm 操作忽略任何現(xiàn)有的屬性設(shè)置,可以省略“數(shù)據(jù)模式”參數(shù),使 Microsoft Access 使用窗體定義的屬性設(shè)置。

示例

下面的示例檢查窗體上所有控件的 ControlType 屬性,并切換每個標(biāo)簽控件和文本框控件的 SpecialEffect 屬性。當(dāng)標(biāo)簽控件的 SpecialEffect 屬性設(shè)置為“陰影”,文本框控件的 SpecialEffect 屬性設(shè)置為“常規(guī)”,AllowAdditions、AllowDeletionsAllowEdits 屬性設(shè)置為 True 時,intCanEdit 變量將切換到允許編輯基礎(chǔ)數(shù)據(jù)的狀態(tài)。

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