编辑后锁定一个字段 [英] lock a field after editing

查看:78
本文介绍了编辑后锁定一个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


去年我问的问题是可以在编辑后锁定一个字段。


Lysander(谢谢Lysander )给了我以下代码:


然后在myName的After_Update事件中输入以下代码

展开 | 选择 | 换行 | 行号

解决方案

您可以使用表格或详细信息部分的当前事件(我记不清哪个)来检查字段中是否有值。如果有,请将其锁定。


从本质上讲,技术上来说,不是。这既不可能,当你意识到你没有锁定某个领域时也没有意义,但是一个控件。


代码适用于锁定控件,但是每次打开表单时都需要锁定字段。因此,无论何时显示字段,您都需要逻辑来确定控件的锁定状态。要锁定特定记录/记录中的字段中的值,您需要清楚的逻辑来确定哪些记录应该具有该控件的锁定状态。


去明智地向前推进我们(不仅是我们,尤其是你)需要理解这种逻辑。


PS。如果您的逻辑与Rabbit猜测的逻辑相匹配,那么表单本身的当前事件确实是如何进行的。


Rabbit,NeoPa,

感谢您的回复。


背后的原因:


我有一个用于收集调查问卷回复的数据库。问卷将在几周内与同一个人重复多达四次。因此,客户端详细信息以一种形式(frmClient)保存,调查问卷响应在frmClient内的子窗体控件(frmQuestionnaire)中。保存数据的表分别是tblClient和tblQuestionnaire。

使用选项组([CompletionNumber])选择响应的数量(即第一个,第二个等)。我不希望客户在返回完成第二个(或第三个等)调查问卷时能够编辑选项组,因为这会覆盖tblQuestionnaire中的数据。


我在[CompletionDate]的AfterUpdate事件([CompletionNumber]之后的表单上的下一个字段)和frmQuestionnaire的OnCurrent事件中使用了以下代码。

展开 < span class =codeDivider> | 选择 | Wrap | Line编号

Hi all,

Last year I asked the question is it possible to lock a field after editing.

Lysander (thanks Lysander) gave me the following code:

Then in the After_Update event of myName put the following code

Expand|Select|Wrap|Line Numbers

解决方案

You can use the on current event of the form or detail section (I can''t recall which) to check if there''s a value in the field. And if there is, lock it.


Essentially, and technically, No. That is neither possible, nor does it make sense when you realise that you are not locking a field that way, but a control.

The code is fine for locking out the control, but locking a field is something you''d have to manage every time the form is opened. Thus, you''d need logic to determine the locked status of the control for whenever the field is displayed. To lock a value in a field in a particular record/records you''d need clear logic as to how to recognise which records should have the locked status for that control.

To go forward sensibly we (Not only us but particularly you) would need to understand that logic.

PS. If your logic matches the logic Rabbit has guessed at, then the Current event of the form itself is indeed how you would go about it.


Rabbit, NeoPa,

Thanks for the responses.

The reasoning behind this:

I have a db used to collect questionnaire responses. The questionnaire is to be repeated up to four times with the same individuals over a period of several weeks. Thus the client details are held in a form (frmClient) with the questionnaire responses in a subform control (frmQuestionnaire) within frmClient. Tables holding the data are tblClient and tblQuestionnaire respectively.

The number of the response (i.e. first, second, etc) is selected using an option group ([CompletionNumber]). I don''t want the client to be able to edit the option group when returning to complete a second (or third etc) questionnaire, as this will overwrite the data in tblQuestionnaire.

I have used the following code in both the AfterUpdate event of [CompletionDate] (the next field on the form after [CompletionNumber]) and in the OnCurrent event of frmQuestionnaire.

Expand|Select|Wrap|Line Numbers


这篇关于编辑后锁定一个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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