简体   繁体   English

MS Access-在特定字段或列上禁用更新

[英]MS Access - Disable Update on a Certain Field or Column

How do we disable update or edit on a certain column for a record. 我们如何在记录的特定列上禁用更新或编辑。 For example I have Product table with fields of ID, Description, Count. 例如,我有产品表,其中包含ID,说明,计数字段。 I want to disable the changes on Description only. 我只想禁用“描述”上的更改。 I know how to do this in sql, but how about in a program for Access or VBA code? 我知道如何在sql中执行此操作,但是在Access或VBA代码的程序中如何执行?

If you're using a form to present the data using a text box control bound to the field, you can lock the field for edits in the field properties. 如果您使用表单通过绑定到字段的文本框控件来显示数据,则可以锁定字段以在字段属性中进行编辑。 The property is called "locked". 该属性称为“锁定”。

You can also use vba code to lock and unlock the field under certain conditions. 您还可以在特定条件下使用vba代码锁定和解锁字段。

Sub form_current ()
If x = "superuser" then
Me!SalaryField.enabled=true
Me!SalaryField.locked=false
Else
Me!Salaryfield.enabled=false 
Me!Salaryfield.locked=true
End if
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM