English 中文(简体)
管理系统接入“记录变化”
原标题:MS Access "record changes" log

每当一个记录被删除或更新时,我想在历史表格中节省其原有价值(删除其订正本)。 我想我必须做以下工作:

http://www.un.org

  • use the BeforeUpdate event to save the data somewhere (collection ? array ? or to a recordset -the Revised table- without saving-yet ?)
  • use the AfterUpdate event to add/save that data to the Revised table

For Deletions

  • use the OnDelete event to save the data - but again how ? several records could be deleted at once since the form (a subform in fact) is in datasheet view
  • use the AfterDelConfirm to add that data to the Revised table.

Do you have any clues, comments or links for this ?
This is all in a "pure Access" (no SQL Server) at the moment. Many thanks !


Edit:与往常一样,适当提问给我的想法是:

  • option 1
    use the BeforeUpdate or the OnDelete to build the SQL statement, and use the AfterUpdate or the AfterDelConfirm to Execute the SQL statement. But that won t work for multiple deletions ?

  • option 2
    have the Revised recordset defined at form level, insert the record "Before" but only Update "After". Again, problem with multiple deletes.

最佳回答

I ve successfully used a variation of Allen Browne s approach in a couple of different projects. Check out his website for more details:

http://allenbrowne.com/AppAudit.html>rel=“nofollow> 建立审计记录

他的解决办法是使用温室和四种通用功能,要求以多种删除的方式处理这一问题。

问题回答

另一种做法 我最近曾考虑过,但没有机会实际执行,即利用交易进行变革跟踪。 基本算法是:

  1. use BeginTrans on the workspace prior to making any changes
  2. in the OnDelete event
    • perform the deletions in code executing Delete queries against the workspace from step 1
    • add a record to your change auditing table
  3. in the BeforeDelConfirm event
    • set Cancel = True
    • display your own Confirmation dialog
    • if user confirms then CommitTrans on workspace
    • otherwise Rollback the transaction on the workspace

Similar approach for Updates/Inserts. This would avoid the need for temporary tables/arrays/collections, etc. but I haven t fully thought through everything. The devil may be in the details.

可用于多个表格的“麻醉”和通用解决办法是建立一个跟踪表,其内容如下:

Track_Table
==================================================
id_track as primary key
id_table as name of the table which has been updated
id_primaryKey as the record identifier (the PK of the updated record)
changeType, being either DEL or UPDATE
changeDate, as dateTime value
fieldName, as text
oldValue, as text or memo
newValue, as text or memo

如果你必须查明哪些用户进行了更新,那么仅增加。

userId

页: 1

然后,你可以创建一些通用的“更新前”和“更新职能后”,以选定形式进行更新和更新活动。 最新数据将储存旧价值,但更新后的功能将储存缺失的数据,并在跟踪表中添加新的记录。

你们必须找到一种办法,找到正确的对应表名称和外地名称。 如果你利用看法或外在别处以表格显示你的数据,那将是困难的。

当然,所要遵循的所有表格必须具有首要关键意义,以便你能够跟踪记录层次的变化。 在多个领域安装的PK肯定会存在问题。

旧价值和新价值必须转换成正文,以便你能够将其储存在文字或电线现场





相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签