保存后,如何获取“访问"表单以防止对字段进行编辑? [英] How can I get my Access form to prevent editing of a field once saved?

查看:49
本文介绍了保存后,如何获取“访问"表单以防止对字段进行编辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格可以用作我的一张桌子的前端.将此表视为与几乎所有其他表都相关的顶级表.一旦填写了此表单,尤其是也填写了其他表格,我真的不希望有人回来编辑该顶级表单中的某些字段.这样做确实会改变整个系统的逻辑.如果我拥有自己拥有的各种运输设备的历史维护记录数据库,并且在20年后将其中一辆车辆从汽车上换成飞机,那将与这类似.历史记录不再有意义.

I have a form that serves as the front end to one of my tables. Think of this table as the top level table for which almost all of the other tables are related. Once this form is filled, and especially once the other tables are also filled, I really don't want someone to come back and edit some of the fields in that top level form. Doing so would really change the logic of the entire system. It would be similar to if I had a database of historic maintenance records for different transportation devices that I own, and after 20 years to change one of the vehicles from a car to an airplane. The historical records wouldn't make sense any more.

所以,如果保存了记录,我希望不要编辑某些字段.删除整个记录并重新开始将是可以的,而更改其他字段将是可以的.只是不更改某些字段.此外,如果用户是第一次创建记录,则可以改变主意.但是一旦保存了记录,那应该是记录的结尾.

So I would like it if once the record is saved, I don't want certain fields from being edited. Deleting the whole record and starting over would be OK, and changing other fields will be OK. Just not changing certain fields. Furthermore, if the user is creating the record for the first time, it should be OK to change their mind. But once the record is saved, that should be the end of it.

我主要希望通过VBA在表单级别上防止这种情况.我认为不可能在数据库级别对其进行保护.

I am primarily interested in preventing this at the form level, with VBA. I don't think it is possible to protect it at the database level.

我在想OnCurrent中的内容,并检查Auto-Incremented ID是否为null,然后编辑就可以了,但是如果ID有值,那么没有编辑?

I'm thinking like something in the OnCurrent, and check to see if the Auto-Incremented ID is null, then edits are OK, but if the ID has a value, then no edits?

推荐答案

tag属性通常非常有用:

The tag property can often be useful:

For Each ctl In Me.Controls
    If ctl.Tag = "SysLock" Then
        ctl.Locked = (Not Me.NewRecord)
<...>

此后,建议您确保表具有创建时间戳记和更新时间戳记.一旦写完这些,就可以防止编辑.例如,可能在过去半小时内创建的任何记录都是公平竞争.

After that, I suggest you ensure that your tables have a create time stamp and an update time stamp. Once these are written, you can prevent editing. It may be that any record created within the last half hour is fair play, for example.

这篇关于保存后,如何获取“访问"表单以防止对字段进行编辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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