+ Reply to Thread
Results 1 to 5 of 5

ComboBox_Change vs _AfterUpdate

  1. #1
    Registered User
    Join Date
    01-23-2009
    Location
    Newark, DE
    MS-Off Ver
    Excel 2002
    Posts
    30

    ComboBox_Change vs _AfterUpdate

    Although I can live with having a Sub run when setting the ComboBox Sub to AfterUpdate...I would really prefer it to be set to _Change. Here is the Sub code that runs after the event:

    Please Login or Register  to view this content.
    When set to _Change...some keystrokes I can enter...other's throw an error at the Else statment. The range it is searching can be empty...or it can have entries. Doesn't seem to be any rhyme or reason for this.

    If I run the same thing with _AfterUpdate...there is no problem at all.

    Any suggestions?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: ComboBox_Change vs _AfterUpdate

    Hello panthers7171,

    What are you trying to do with ComboBox? What type is it a Forms or Control Toolbox control?

  3. #3
    Registered User
    Join Date
    01-23-2009
    Location
    Newark, DE
    MS-Off Ver
    Excel 2002
    Posts
    30

    Re: ComboBox_Change vs _AfterUpdate

    Quote Originally Posted by Leith Ross View Post
    Hello panthers7171,

    What are you trying to do with ComboBox? What type is it a Forms or Control Toolbox control?
    These are from the Control Toolbox.

    When combobox set to _AfterUpdate:

    The combobox is populated by another Sub prior to it gaining focus. Sometimes the combobox will have no items in it...sometimes it will have some items in it. Regardless...I can either enter a new value using any keyboard entry...or I can select a pre-populated item. Either way...upon focus leaving the combobox...it calls the Sub listed in my first post which then updates a text box depending on what I entered/choose in the combobox. This all works fine.

    When combobox set to _Change:

    Same as above in some respects. I can definitely choose an Item in the combobox that is pre-populated. I can attempt to enter a manual value...but only if I start the entry with certain keys. To top it off...it seems that the keys that work/dont work change sometimes. When things don't work I get an error in the following line of the Sub that is called.

    Here is the code again:

    Please Login or Register  to view this content.
    The error it gives me points to the "Else" statement.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: ComboBox_Change vs _AfterUpdate

    Hello panthers7171,

    This find line of code maybe the problem, especially if you are using the Find method elsewhere in your code. Find remembers most of the arguments. It is a good practice to set them all when calling this method. Because this method calls the Windows Find routine, using Find to do manual searchs will change the argument values also. It may be a pain because it is more code, but it is less hassle in the long run.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Registered User
    Join Date
    01-23-2009
    Location
    Newark, DE
    MS-Off Ver
    Excel 2002
    Posts
    30

    Re: ComboBox_Change vs _AfterUpdate

    Quote Originally Posted by Leith Ross View Post
    Hello panthers7171,

    This find line of code maybe the problem, especially if you are using the Find method elsewhere in your code. Find remembers most of the arguments. It is a good practice to set them all when calling this method. Because this method calls the Windows Find routine, using Find to do manual searchs will change the argument values also. It may be a pain because it is more code, but it is less hassle in the long run.
    Please Login or Register  to view this content.
    Awesome! I replaced my code with yours...and after a little minimal testing it appears to be working great!

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1