开发者

Detecting data changes with Form events

开发者 https://www.devze.com 2023-01-29 13:14 出处:网络
If you\'ve read my other recent questions, you\'ve prob\'ly picked up that I\'m not really an Access developer.... Most of my background is in VB, where I assiduously avoided bound controls.

If you've read my other recent questions, you've prob'ly picked up that I'm not really an Access developer.... Most of my background is in VB, where I assiduously avoided bound controls.

Now I'm working in Access 2007. I have form that's based on a table (well, a single-table query), and a subform upon it based on a one-to-many child table开发者_JAVA百科. I want to detect user-made changes in the data on either of these forms so that I can update a date stamp in the parent table. The actual date field is not being shown to the user (at least not here).

What would be the appropriate event to catch the fact that the change has been made? How should I make the actual change (direct to form.Recordset!dateField | with a hidden bound text box | some other way)?


You'll have to look for the afterupdate event, which is fired when the updated content of a bound control is updated in the underlying recordset.

In this event procedure, you should be able to write the needed instruction to update your date field. It is not necessary to have it bound to any control on the form, as long as the field is in the recordset!


I think you can make a trigger to update the stamp of the child table per line of item that the user have made changes. I normally use it on afterupdate event in relation to the index number of the active line (if you are in a datasheet form or continues form) being edited. But of course you can count on how many times each record was updated and you can update the stamp date of the last update.

0

精彩评论

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