Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoid form updates when switching focus to contained subform

Status
Not open for further replies.

mabris

Technical User
Mar 23, 2005
10
US
I have an audit trail/electronic signature/ undo feature built built with VBA into my Access forms. It runs on the BeforeUpdate event of the main form. The problem I am having though is that I do not want the audit trail stuff to fire when i am simply moving the focus from the main form to a subform on the main form. I only want it to go when i am changing records or actually leaving the form. Any hints on as to how I can avoid the before update event on the main form when switching the focus to the main form?
 
But isn't the BeforeUpdate event fired because the record'll change ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well, maybe I should give a little more info. This is an example of the type of thing i'm doing, but there are lots of variations on this in this project.

The main form displays infor for an analytical lab sample. contained in the main form is a subform that displays info on each test assigned for the sample. I wish the auidt trail function to fire only when the main form changes which sample is being displayed or when the form itself is closed.

Currently, the audit trail function will fire when I haven't navigated away from the the sample record on the main form, but when I have simply attempted to move focus to the subform window. I wish to allow the user to do the audit trail stuff only when changing sample records, not when trying to change data on the sub form (the data for which is a separate recordset from the main form).

So, I need a work-around that would allow me to avoid the my audit trail when just moving focus to a subform, but keep it functional for things like navigating away from the record.

 
But if Me.Dirty = True when you move focus to the subform, the BeforeUpdate event fires and the record changes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
By moving focus to a subform, you have effectively navigated away form your main form, hence cause Access to update your main form's record.

This is what PHV is saying
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top