Update Query Question

illy2k

Registered User.
Local time
Today, 16:30
Joined
Apr 21, 2003
Messages
51
Is there anyway to automate my update query, so that when I leave a form the query runs automatically in the background? And is fully automatic?
 
You can set up a macro or a piece of code that activates your query if you go to the properties of the form and set up your macro or code inside the 'On Deactivate' on the 'Event' tab.
 
If you are 100% sure that you want the update query to act whenever the user "leaves" the form, then you could use the code:

Code:
Private Sub Form_Deactivate()
DoCmd.SetWarnings False
DoCmd.OpenQuery "QueryName"
DoCmd.SetWarnings True
End Sub


Worth noting: Quoted from AccHlp

Deactivate Event
The Deactivate event occurs when a form or report loses the focus to a Table, Query, Form, Report, Macro, or Module window, or to the Database window.

Remarks
When you switch between two open forms, the Deactivate event occurs for the form being switched from, and the Activate event occurs for the form being switched to. If the forms contain no visible, enabled controls, the LostFocus event occurs for the first form before the Deactivate event, and the GotFocus event occurs for the second form after the Activate event.

When you first open a form, the following events occur in this order:

Open Þ Load Þ Resize Þ Activate Þ Current

When you close a form, the following events occur in this order:

Unload Þ Deactivate Þ Close

HTH

Brad
 

Users who are viewing this thread

Back
Top Bottom