开发者

Access behaviour - it wants to update records, I want it to insert new ones, track old ones via timestamp

I am designing a database where I wish to track changes in my tables, in this case the "person" table, such that what appears in my Access user interface to be an edit to a person record, actually appears in my PostgreSQL backend to be a new record, with a timestamp and username field reflecting the time and person that made that edit.

First of all, I've never attempted a design like this to begin with, so some reassurance that I'm going about this sensibly would be nice. My primary question, however, is how to implement this. In general, Access forms seem very much designed t开发者_如何学Pythono edit records, and I'm not sure how I can cleanly go about changing its behaviour to insert new ones instead.

As I understand it, the BeforeUpdate event fires before a database-level update. What I'd love to do is edit my form's BeforeUpdate method with code something like:

  1. Cancel the database update
  2. Update the timestamp in Access for the record it's working with
  3. Null the recordid field from the record, which is an auto_increment primary key, so that on insert, a new recordid will be assigned automatically.
  4. Insert a new copy of the record I'm working with in Access
  5. If necessary (I think it is?), point my access form to the new record it just inserted (by the way, how do I actually find the new record I inserted? Can I get a reference to it during the insert, or to the auto-incremented primary key that was generated?)

Thanks for any help anyone can provide.


I would allow Access to update its tables and just create an insert statement to your PostgreSQL backend. You can use it as your log. Trying to switch out the current record in access just seems to complex and unecessary. Changing the primary key is uncessary and should be used to reference the changed data records in the other database.

You can use VBA in the code behind the form and just create another record with the current data, but use the Now() function for the timestamp value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜