salad --
Thanks very much! Actually, I ended up doing things another way. If
the user wants to trigger the "event" I was talking about (running a
SAS program using the "shell" VBA function), they press the Cntl-R key
before closing the form. In the VBA code, I create a a variable:
"Public do_sas As Integer" (this must apparently be placed at the top
of the VBA code), and use the KeyPress event of the form with the
code: "If KeyAscii = 18 Then do_sas = 1". The OnClose event of the
form checks if do_sas is equal to 1, and if so, when the user closes
the form, the VBA sets do_sas back to 0 (don't know if this is
necessary) and goes ahead with the "shell" function to submit the SAS
job.
Oh -- in order to make the form "see" the Cntl-R key press, I had to
set the form's "Key Preview" property to "Yes".
Thanks again for your assistance,
--Tom
email: frethoa AT aol DOT com
On Feb 7, 5:09 pm, salad <o...@vinegar.comwrote:
Tom_F wrote:
To comp.databases.ms-access --
I would like to trigger an event when I close a form -- but ONLY when
the data in the "RecordSource" table has been updated. I tried using
the AfterUpdate event, but it fires multiple times when the form is
closed ... and I only want my event to be triggered once. Could
someone tell me a good way to do this? I'm using Microsoft Access
2003. Thanks very much!
--Tom
email: frethoa AT aol DOT com
Well, you know that if the event passes the error checks and is not
canceled, the record was updated.
I suggest you enter, under the declarations section, something like
Dim blnUpdated As Boolean
And if it passes all checks in the BeforeUpdate of the event, enter
blnUpdated = True
and in the OnClose event
If blnUpdated then
...