AllowEdits 屬性

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

expandtri全部顯示

使用 AllowEdits 屬性可以指定用戶是否可在使用窗體時編輯已保存的記錄。Boolean 型,可讀寫。

expression.AllowEdits

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

設(shè)置

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

設(shè)置

Visual Basic

說明

True

(默認(rèn)值)用戶可以編輯已保存記錄。

False

用戶不能編輯已保存記錄。

 

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

說明

如果要防止更改窗體中顯示的現(xiàn)有數(shù)據(jù),可以使用 AllowEdits 屬性。如果要防止更改特定控件中的數(shù)據(jù),可以使用 EnabledLocked 屬性。

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

AllowEdits 屬性設(shè)置為“否”時,“刪除記錄”或“數(shù)據(jù)輸入”菜單命令對現(xiàn)有記錄將不可用。(如果將 AllowAdditions 屬性設(shè)為“是”,則其對新記錄將仍然可用。)

無論 AllowEdits 屬性的設(shè)置如何,通過編程對字段值進(jìn)行的更改都會使當(dāng)前記錄可被編輯。如果要防止用戶對需要通過編程才能編輯的記錄(AllowEdits 為“否”)進(jìn)行更改,請?jiān)谒谐绦蚧暮蟊4嬗涗?;保存完針對?dāng)前記錄未保存的所有更改后,AllowEdits 屬性設(shè)置將再次發(fā)揮作用。

注釋  如果設(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è)置為“普通”,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