如何防止意外删除子表单中的记录 [英] How to prevent accidental deletion of record in subform

查看:81
本文介绍了如何防止意外删除子表单中的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用Access 2013


我有一个未绑定的子表单,我在VBA中填充SQL查询,方法是创建一个querydef并将其传递给子表单源控件。子表单显示在数据表视图中。我有一个用户不小心通过子表单删除了一条记录,我想确保不再发生这种情况。我尝试将allow deletions属性设置为no但该属性不会显示在子表单属性中。它确实显示在主窗体中但是如果我将其设置为否即使主窗体被锁定,它们仍然可以通过子窗体删除记录。我不想锁定子表单,因为人们仍然需要编辑子表单中的值,但我想消除用它删除任何记录的机会。


我有什么东西可以俯瞰吗?我试过在互联网上搜索,没有找到任何运气。


任何帮助都会受到赞赏。

谢谢,

Rodney

Hello, I''m using Access 2013

I have an unbound sub form that I''m populating with a SQL query in VBA by creating a querydef and passing it to the sub form source control. The sub form is shown in datasheet view. I had a user accidentally delete a record through the sub form, and I want to make sure that doesn''t happen again. I tried setting the allow deletions property to "no" but that property doesn''t show up in the sub form properties. It does show up in the main form but if I set that to "no" they can still delete a record through the sub form even though the main form is locked. I don''t want to lock the sub form because people still need to edit values in the sub form, but I want to eliminate the chance of deleting any records with it.

Is there something I''m overlooking? I''ve tried searching the internet and have not had any luck finding anything.

Any help would be appreciated.
Thanks,
Rodney

推荐答案

每个表单都有一个 AllowDeletions 属性。如果您将表单设置为 True 作为子表单,那么它应该禁止删除,同时允许编辑。


某些属性通过其他操作重置,例如设置 RecordSource 属性并打开包含特定参数的表单,因此在表单运行后检查属性的值。如果它自动重置,那么在运行时添加一些代码将其设置为 True
Each form has an AllowDeletions property. If you set that to True for the form that you''re using as a Sub-form then it should disallow deletions while allowing edits.

Certain properties get reset by other actions, like setting the RecordSource property and by opening the form with particular parameters, so check the value of the property once the form is running. If it gets itself reset then add some code to set it to True when it''s run.


NeoPa感谢您的快速响应。


如果我不想让他们删除字段,难道我不能将 AllowDeletions 设置为 False 吗?另外,我有一个组合框选择器,可以将RecordSource从一个表更改为一个表,每次RecordSourse改变时,我添加了一段代码来将Allow Deletions属性设置为false,但是如果我在子窗体中选择一个记录并且无效按删除它会被删除。


我已经尝试将表单中的AllowDeletions设置为true和false,但它并没有什么区别。 />

不确定这是否有任何区别但是对于属性这是我在主窗体上得到的,并且这些属性都不会显示在子窗体上。


数据输入 - 设置为是(我只希望他们在主窗体中添加新数据。)

允许添加 - 设置为是

允许删除 - 设置为否

允许编辑 - 设置为是

允许过滤器 - 设置为否


谢谢,

Rodney
NeoPa thank you for the quick response.

Shouldn''t I set AllowDeletions to False if I don''t want them to delete fields? Also, I have a combo box selector that changes the RecordSource from table to table, I added a chunk of code to set the Allow Deletions property to false every time the RecordSourse changes, but to no avail if I select a record in the subform and press delete it get''s deleted.

I''ve tried setting the AllowDeletions in the form to true, and false, but it didn''t make a difference.

Not sure if this makes any difference but as for properties this is what I''ve got on the main form, and none of these properties show up on the sub form.

Data Entry - set to yes (I only want them do add new data in the main form.)
Allow Additions - set to yes
Allow Deletions - set to no
Allow Edits - set to yes
Allow Filters - set to no

Thanks,
Rodney


这是我用于设置表单的代码的一部分。

在这种情况下,一个监督相关表允许编辑记录;但是,我不希望直接添加或删除子记录,因为这些需要记录/验证以用于审计原因:
This is part of my code used to setup forms.
In this case, a supervisor for a related table to allow editing of a record; however, I don''t want additions nor deletions directly to the child records as these need to be recorded/validated for auditing reasons:
展开 | 选择 | 换行 | 行号


这篇关于如何防止意外删除子表单中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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