473,839 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

52 New Member
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.DoMenuIte m 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 2426
MMcCarthy
14,534 Recognized Expert Moderator MVP
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.DoMenuIte m 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
gazelle04
52 New Member
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 New Member
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
1714
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 page by clicking browsers back button? What I'd like to do is give focus to a text field of a form when the page is loaded, but not when the page is "reused" by clicking on a back button. Can this be done with javascript?
2
4407
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 separate unbound form with all the fields, which are on the subform. The fields are filled in with data programmatically. User edits. Edited fields are copied into fields on the subform programmatically as well. I need to catch change in one of...
3
2925
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 sbfrmAnswers. I put an option group (optAnswers) on the subform with buttons for true or false. To speed entry of the results of the 350+ surveys we've collected, I put the following code in the AfterUpdate event of the option group: With...
5
3952
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 next question to be answered, as a visual cue for the user. After the user has answered all questions, they click on the "Save" button to save their answers. My problem is that they have to click on "Save" twice because the AfterUpdate event...
7
1732
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 information to tie the signature to the key(s) issued. When the information is added to the form, the user clicks on a command button to save and exit the form; Private Sub Command71_Click() On Error GoTo Command71_Error If Not...
18
1691
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, without clicking the submit button, thus losing the data. Can someone point me to a generic example of some code that will trap and handle this error?
13
8647
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 OnGetFocus event of the combo box control, and this appears to work...I'm guessing because one cannot click on the drop down arrow of a combo box control without first having the combo box control receive focus. But I noticed that the code gets...
2
5213
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 of the table, a submit button is added. Almost everything works fine. The form display, the user fills out the form and then click Submit. However, the first time the submit button is clicked, the Click event isn't raised. Just a simple...
26
4169
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 Binding_Percentage_AfterUpdate() 'Updates the Total calculation in the control "SumGWP" and "SUMNWP"on the quick reference 'table on the Forecast form With Me! And Me! And Me! And Me!
0
9856
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9698
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10914
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10597
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10656
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5872
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4071
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.