473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Trigger event when close form, but ONLY when update record in table?

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

Feb 7 '07 #1
2 5378
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
...

Feb 7 '07 #2
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
...

Feb 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Neil Rutherford | last post by:
During testing of an application, i noticed a difference between SQL 2000 and SQL 7, both with identical config. In a nutshell: A table has a trigger for UPDATE and DELETE. When a column in the...
7
by: rkrueger | last post by:
Given the following 3 Tables: CREATE TABLE ( NOT NULL , NOT NULL CONSTRAINT DEFAULT (getdate()), NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
10
by: Anton.Nikiforov | last post by:
Dear all, i have a problem with insertion data and running post insert trigger on it. Preambula: there is a table named raw: ipsrc | cidr ipdst | cidr bytes | bigint time | timestamp...
4
by: michael.kirby | last post by:
I have been reading up on triggers and I am still unclear as to the best way to accomplish the following: Each row in table A has an account number field. After insert of record 1 into table A,...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the...
11
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
5
by: Prabu Subroto | last post by:
Dear my friends... I am using SuSE Linux 9.1 and postgres. I am a beginner in postgres, usually I use MySQL. I have 3 tables : appointment, appointment0 and appointment1. the fields of...
13
by: Keith Wilby | last post by:
I've never used this event before and I'm struggling. I have this code in it: If MsgBox("You entered " & Me.cboManagerName _ & " - is this the manager's network logon ID?", vbYesNo, "Confrim...
3
by: Sam Durai | last post by:
Need help to write a trigger according to the following business requirement. This on DB2 UDB V8.2 / AIX 5.3 Whenever a 100th record is inserted into my 'ACCOUNT' table with a particular...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.