如何创建命令按钮以将修改后的记录添加为新记录? [英] How to create a command button to add modified records as a new record?

查看:75
本文介绍了如何创建命令按钮以将修改后的记录添加为新记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个表单,供用户在表格中输入数据。在用户检索记录之后,我希望他们能够对现有记录进行更改并将此更改添加为表中的新记录,而不会丢失或覆盖旧/原始记录。当我从表中的字段中删除主键时,这将工作并创建多个欺骗记录。我不想复制主键字段没有变化的记录。


我有一张桌子CCTRACKING和字段是:

ID

* REQID

* RECDT

* ENTITY

* FINLDT

原因

评论

CUST

限制


带*的字段是此表的唯一主键字段

解决方案

您的要求与关系完整性冲突,因此无法将修改存储为单独的记录在与原始记录相同的表中。


确实没有必要将数据存储在同一个表中。您可以创建一个日志表,在其中记录记录的主键,更改的字段名称,原始值,修改后的值,更改者以及更改的日期/时间。您可以使用每个控件的更新后事件从VBA代码向更改日志添加记录,使用每个控件的OldValue属性来恢复相关的更改前值。


-Stewart


感谢您的回复。如果我设置一个新表来存储每个新修改的记录,我将如何能够以相同的形式恢复最新的记录以进行其他更改?我正在尝试创建记录历史和所做的更改。


您需要使用存储在日志文件中的先前值并从最年轻的更改恢复到您考虑的任何状态通过将更新的字段值替换为其先前(旧)值来适当。我无法确切地说明这一点,因为它完全取决于您决定监控哪些字段并将其复制到更改日志中,以及您希望撤消哪些更改级别的策略。


我不像你那样了解你的应用程序,但我会以你目前设想的方式实现变更记录时要谨慎。你在保护什么?为什么要撤消对某些记录进行的编辑?您的标准是什么决定变更是不合法的,必须撤消?您希望撤消多少级别的更改(请记住,用户可能会多次更改相同的字段值,例如通过编辑和重新编辑注释)?


-Stewart

I have created a form for users to enter data in a table. After a user retrieves a record, I want them to be able to make a change to the existing record and ADD this change as a new record in the table without losing or overwriting the old /original record. When I remove the primary key from the fields in the table, this works and creates multiple dupe records. I don''t want to duplicate the records where there is no change to the primary key fields.

I have a table "CCTRACKING" and Fields are:
ID
*REQID
*RECDT
*ENTITY
*FINLDT
REASON
COMMENT
CUST
LIMIT

The fields with * are the unique primary key fields for this table

解决方案

Your requirement conflicts with relational integrity, so there is no way to store the modifications as a separate record in the same table as the original record.

There really is no need to store the data in the same table. You can create a log table in which you record the primary key of the record, the name of the field changed, its original value, its modified value, who changed it, and the date/time of the change. You could add a record to the change log from VBA code using the after-update event of each control to do so, using the OldValue property of each control to recover the pre-change value concerned.

-Stewart


Thanks for your reply. If I set up a new table to store each new modified record, how will I be able to recover the most current record in the same form to make additional changes? I am trying to create a history of records and the changes made.


You would need to use the previous values stored in the log file and recover back from the youngest changes to whatever state you considered appropriate by replacing the updated field values with their previous (old) values. I can''t be precise about this because it will depend entirely on what fields you decide to monitor and copy into the change log, and on your policies on what change levels you would wish to undo.

I do not know your application the way you do, but I would be cautious about implementing change logging in the way you appear to be envisaging it at present. What is it you are protecting against? Why would you wish to undo edits that have been made to some records? What would your criteria be for deciding that a change is not legitimate and must be undone? How many levels of changes would you wish to undo (bearing in mind that a user may change the same field value several times, by editing and rewording comments for instance)?

-Stewart


这篇关于如何创建命令按钮以将修改后的记录添加为新记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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