输入数据后如何锁定文本框 [英] How do I lock a text box after data has been entered

查看:238
本文介绍了输入数据后如何锁定文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用我的表单中的文本框,以便在保存记录后向空单元格添加信息。 

I am trying to make my textboxes in my form to be able to add information to empty cells after the record has been saved. 

例如。我的CustomerF有姓名,地址,Contact_Name,Contact_Number等。有人在数据库中添加了一个没有联系号码的新客户。我希望能够进入记录并且只能编辑空文本框,并且已锁定所有其他(已填充
)文本框。 

e.g. My CustomerF has Name, Address, Contact_Name, Contact_Number, etc. Someone adds a new customer into the database with no contact number. I want to be able to go in to the record and only be able to edit the empty textbox, and have all of the other (already filled) textboxes locked. 

我尝试提交此代码,但无法使用。 

I tried to submit this code, but it didn't work. 

Private Sub Contact_Name_Click()

   如果Me.Contact_Name = Empty则为
        Me.AllowEdits = True

   否则

        Me.AllowEdits = False

   结束如果

结束子

Private Sub Contact_Name_Click()
    If Me.Contact_Name = Empty Then
        Me.AllowEdits = True
    Else
        Me.AllowEdits = False
    End If
End Sub

此外,有没有办法以一般方式执行此操作而无需为每个项目编写代码?

Also, is there a way to do this in a general way without having to write code for each item?

推荐答案

在我的公共数据库文件夹中查看LockForm.zip:



https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912 !169



请注意,如果您使用的是早期版本的Access,您可能会发现某些表单对象(如按钮)的颜色显示不正确而且您需要 相应地修改表格设计。  
$


如果您无法打开链接,请复制链接(NB,而不是链接位置)并将其粘贴到浏览器的地址栏中。


这个小小的演示文件说明了如何准确地完成你的想法。
Take a look at LockForm.zip in my public databases folder at:

https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

Note that if you are using an earlier version of Access you might find that the colour of some form objects such as buttons shows incorrectly and you will need to  amend the form design accordingly.  

If you have difficulty opening the link, copy the link (NB, not the link location) and paste it into your browser's address bar.

This little demo file illustrates how to do exactly what you have in mind.


这篇关于输入数据后如何锁定文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆