473,386 Members | 1,745 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,386 software developers and data experts.

Which happen first - AfterUpdate of form or Clicking a button on a form

Which happens first AfterUpdate event of a form or Clicked event of a button on a form.

I have these codes on an AfterUpdate of a form:
If UpdateDone = True Then
UpdateDone = False
MsgBox "A record has been changed"
End If

I also have these on a save command button on a form:

If UpdateDone = True Then

UpdateDone = False

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If

When I close the form or moved to another form, the AfterUpdate event always fire although I already clicked the command button. How can I prevent the AfterEvent of a form from firing after clicking a command button.
Sep 18 '06 #1
3 2406
MMcCarthy
14,534 Expert Mod 8TB
Even though the After Update is running when you have already used a command button. The code has already reset UpdateDone to False so the condition in the After Update shouldn't be true. Is there something else going on to reset the UpdateDone button to True?



Which happens first AfterUpdate event of a form or Clicked event of a button on a form.

I have these codes on an AfterUpdate of a form:
If UpdateDone = True Then
UpdateDone = False
MsgBox "A record has been changed"
End If

I also have these on a save command button on a form:

If UpdateDone = True Then

UpdateDone = False

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End If

When I close the form or moved to another form, the AfterUpdate event always fire although I already clicked the command button. How can I prevent the AfterEvent of a form from firing after clicking a command button.
Sep 18 '06 #2
Even though the After Update is running when you have already used a command button. The code has already reset UpdateDone to False so the condition in the After Update shouldn't be true. Is there something else going on to reset the UpdateDone button to True?

UpdateDone is a variable in the BeforeUpdate of the form, it is here

For Each C In Me.Controls
Select Case C.ControlType
Case acTextBox, acComboBox
If C.Value <> C.OldValue Then
UpdateDone = True
End If
End Select
Next C

I used that to check if the record is really changed and not just clicking on the text boxes or combo boxes.

Then I have Save button that changes the UpdateDone variable to false so that when I close move to another form the AfterUpdate will not fire. Acutally I'm using a Tab control with subform on each. These codes are in the subforms events. I used the AfterUpdate event of the subform to catch if there are changes in records whenever I moved to another page of the Tab control.

The problem is every time I clicked any button the AfterUpdate event of the form fires.
Sep 18 '06 #3
misscrf
13
Just a thought that may help for this and other troubleshooting. Put a stop in front of each procedure. See which gets hit first.
Sep 18 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Igor Planinc | last post by:
Is it possible to differentiate between the followig two cases: 1. user comes to a page by clicking on a link, submitting a form or some other (?) "regular" way, and 2. user comes to that same...
2
by: Galina | last post by:
Hello I have an application in MS Access 2000. I have a form, which includes a subform. The subform is based on a table, but locked for any editing. There is Edit button. When clicked, it starts a...
3
by: jdph40 | last post by:
In Access 2002, I designed a simple database for our Safety department to enter results of a survey. There are 41 true/false statements. I have a main form called frmSurvey with a subform called...
5
by: EManning | last post by:
I'm developing an unbound form with a series of questions on it. Each question is either a text box or an option group. I have coding in the AfterUpdate event of each control to highlight the...
7
by: pltmcs | last post by:
I have a form that keeps track of keys given to employees. We decided to add a feature to keep a digital signature for the keys so I created a second table to hold the signature and enough...
18
by: Fester Bestertester | last post by:
Greetings, I'm an occasional php/mysql dabbler. I have a basic data form with a submit button. Unfortunately, it's still possible for the user to enter data changes and close the window,...
13
by: mirandacascade | last post by:
I want to set things up such that a section of code will have been executed by the time one clicks on the drop down arrow on a combo box control. Currently, that section of code resides in the...
2
by: William | last post by:
Hi I've created a page with only 'n blank table control on it. When clicking a button, the table populates with various textboxes and dropdown lists to make up a complete form. In the last row...
26
kcdoell
by: kcdoell | last post by:
Hello: I have a continuous form that displays records. In the AfterUpdate event of one of the fields, Binding_Percentage, I have the following code: Private Sub...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.