Solved

Change Versus AfterUpdate

Posted on 2007-12-03
6
1,433 Views
Last Modified: 2010-05-18
I have a very simple question...When i double click on a textbox or combobox while in design mode in VBE it adds a sub procedure like Sub Textbox1_Change()....It never adds Sub Textbox1_afterupdate....I have used both and can't tell the difference....What is the difference between these two and is one better than the other?
0
Comment
Question by:ToddHawley4984
6 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 20397544
>What is the difference between these two and is one better than the other?
In my experience the only time Change is used is with tab controls, when a user clicks on a tab it fires the tab control Change event.  Otherwise, use AfterUpdate.
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 50 total points
ID: 20397576
Neither is intrinsically better than the other--it's a matter of what you need to, and picking the
right event to handle it.

For textboxes...
The Change event fires as soon as you start typing in the textbox.  AfterUpdate does not
fire until after you tab off of the control, basically.  So, if I want to enter "foo" into a text box,
the Change event would fire three times, and AfterUpdate just once.  There is also a
BeforeUpdate event that I find extremely useful if I need to validate entries.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 20397592
Jim,

I'll use the Change event with list-only comboboxes.  I stay away from the Change event in
textboxes for the reason stated above :)

Regards,

Patrick
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 65

Expert Comment

by:Jim Horn
ID: 20397614
{a qualification on my earlier comment }
Most of that is from Access VBA experience.  Excel VBA or VB may differ, and if so matthewspatrick would know it.
0
 
LVL 9

Expert Comment

by:antontolentino
ID: 20398679
change event is useful if you want to simulate the auto complete suggestion list
0
 

Author Closing Comment

by:ToddHawley4984
ID: 31412398
Great thats what i was missing Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
First Blank Cell in a range 7 34
Create Form using Wizard 14 31
Hard coding time and date into Excel 2 30
Excel macro runs twice 13 46
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Outlook Free & Paid Tools
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now