ComboBox.Locked 屬性 (Access)ComboBox.Locked property (Access)

Locked 屬性會指定您是否可以編輯控制項在表單檢視中的資料。The Locked property specifies whether you can edit data in a control in Form view. 可讀寫的 BooleanRead/write Boolean.

語法Syntax

運算式鎖定expression.Locked

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.

註解Remarks

Locked 屬性的預設設定為 TrueThe default setting of the Locked property is True. 此設定允許編輯、 新增、 和刪除資料。This setting allows editing, adding, and deleting data.

Locked 屬性可以用於以使其成為唯讀保護欄位中的資料。Use the Locked property to protect data in a field by making it read-only. 例如,您可能會想僅不允許編輯,顯示資訊的控制項或可能會想要鎖定控制項之前,以符合特定條件。For example, you might want a control to only display information without allowing editing, or you might want to lock a control until a specific condition is met.

範例Example

下列範例會切換命令按鈕的 Enabled 屬性和 EnabledLocked 屬性的控制項,根據目前的記錄中顯示的員工的類型。The following example toggles the Enabled property of a command button and the Enabled and Locked properties of a control, depending on the type of employee displayed in the current record. 如果員工是 manager, SalaryDetails ] 按鈕隨即啟用並PersonalInfo控制項已鎖定並啟用。If the employee is a manager, the SalaryDetails button is enabled and the PersonalInfo control is unlocked and enabled.

Sub Form_Current() 
 If Me!EmployeeType = "Manager" Then 
 Me!SalaryDetails.Enabled = True 
 Me!PersonalInfo.Enabled = True 
 Me!PersonalInfo.Locked = False 
 Else 
 Me!SalaryDetails.Enabled = False 
 Me!PersonalInfo.Enabled = False 
 Me!PersonalInfo.Locked = True 
 End If 
End Sub

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.