Results 1 to 9 of 9
  1. #1
    Star Lounger
    Join Date
    Jan 2002
    Location
    Hunt Valley, Maryland, USA
    Posts
    88
    Thanks
    58
    Thanked 0 Times in 0 Posts

    Thumbs up

    A client has a model in Excel2003 with fifteen userforms. For the text boxes and combo boxes in those userforms, some of them have the _Change event, and others have the _AfterUpdate event.

    As far as my research in microsoft.com and MSDN has shown, Microsoft doesn't want to be bothered with explaining these events types, and in particular whether they are interchangeable.

    Does anyone know of a web site/web page which reasonably explains these two event types for these two control types (or for all control types)? If not, can anyone at least explain whether _AfterUpdate is the better choice, whether _Change is the better choice, or something like that?

    Thanks in advance.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    If you use the Change event of a textbox it occurs whenever the textbox changes - i.e. it fires for each character you type in the textbox. The AfterUpdate event is triggered once as you leave the textbox, between the BeforeUpdate and Exit events.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    To expand on Rory's comments, which is better will depend on what you are using it for.

    If you want to validate the entry, you can validate the entire entry in the AfterUpdate event, but if you have a complicated entry where some items are particular characters (these are numbers those are alphabetic, some are either, some only particular letters or numbers, etc) , instead of waiting for the end to point out all the errors, you could use the Change event to look at each one to validat it char by character

    Steve

  4. #4
    Star Lounger
    Join Date
    Jan 2002
    Location
    Hunt Valley, Maryland, USA
    Posts
    88
    Thanks
    58
    Thanked 0 Times in 0 Posts
    [quote name='rory' post='766823' date='23-Mar-2009 10:24']If you use the Change event of a textbox it occurs whenever the textbox changes - i.e. it fires for each character you type in the textbox. The AfterUpdate event is triggered once as you leave the textbox, between the BeforeUpdate and Exit events.[/quote]
    Rory:
    - And do these remarks apply to combo boxes as well?
    - Isn't there a Microsoft document/publication which provides a brief explanation of the various events available? I know that I have seen one, about five years ago. I'm not picky -- doesn't have to be a Microsoft document...
    Thanks very much for the response.

  5. #5
    Star Lounger
    Join Date
    Jan 2002
    Location
    Hunt Valley, Maryland, USA
    Posts
    88
    Thanks
    58
    Thanked 0 Times in 0 Posts
    [quote name='sdckapr' post='766851' date='23-Mar-2009 12:16']To expand on Rory's comments, which is better will depend on what you are using it for.

    If you want to validate the entry, you can validate the entire entry in the AfterUpdate event, but if you have a complicated entry where some items are particular characters (these are numbers those are alphabetic, some are either, some only particular letters or numbers, etc) , instead of waiting for the end to point out all the errors, you could use the Change event to look at each one to validat it char by character

    Steve[/quote]
    Steve:
    That's helpful. I won't use Change for this app, then, because there are just numbers with which they are dealing and because there are a total of ~75 text boxes plus ~30 combo boxes. It already acts sluggish. Much obliged.

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    [quote name='JohnSimkins' post='766956' date='24-Mar-2009 00:44']Rory:
    - And do these remarks apply to combo boxes as well?
    - Isn't there a Microsoft document/publication which provides a brief explanation of the various events available? I know that I have seen one, about five years ago. I'm not picky -- doesn't have to be a Microsoft document...
    Thanks very much for the response.[/quote]

    Yes, it is the same for the combobox - the change event fires whenever the value changes. (a combobox is basically a textbox and a listbox)
    I think there used to be a reference on MSDN, but I'm damned if I can find it. I will post back if I do locate one.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

  8. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    [quote name='JohnSimkins' post='766957' date='24-Mar-2009 00:53']there are a total of ~75 text boxes plus ~30 combo boxes[/quote]

    Forgot to mention - if you are using the same code for some or all of those textboxes and comboboxes, I hope you are using class modules!
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #9
    Star Lounger
    Join Date
    Jan 2002
    Location
    Hunt Valley, Maryland, USA
    Posts
    88
    Thanks
    58
    Thanked 0 Times in 0 Posts
    [quote name='sdckapr' post='766992' date='24-Mar-2009 06:27']Does this help:
    http://msdn.microsoft.com/en-us/library/aa155610.aspx

    Steve[/quote]
    Steve: Thank you for pointing me to that reference -- it's a keeper! In the current matter, though, I want something similar, but which explains only the events belonging to controls on the form, not the form.
    So far, your post sdckapr @ 23-Mar-2009 12:16 has been the most help. Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •