+ Reply to Thread
Results 1 to 3 of 3

Refreshing data in listbox on userform fires it's afterupdate event a second time

  1. #1
    Registered User
    Join Date
    09-24-2016
    Location
    SoCal
    MS-Off Ver
    2013
    Posts
    2

    Refreshing data in listbox on userform fires it's afterupdate event a second time

    Caveat - this is my first post after my introduction post.

    Excel 2013. (VBA) I open a user form from a custom ribbon button. Form has listbox which is populated with service order data from an access database. On clicking on a listbox line item - the listbox_afterupdate event fires running code that in essence updates the selected service order status to "Scheduled" among other stuff. This all works fine.

    What I want to happen is for the listbox data to be refreshed since the criteria for filling the listbox is the service order status is "Unscheduled". I.e., I don't want to have to close and re-open the form to update the data. This used to work, but while working with the code I did something to break it. I get the following error when the after update event runs again - "Runtime error 381...Could not get the column property. Invalid property array index." I understand why the error is there, I just don't want the event to run twice. Here is my code...

    Please Login or Register  to view this content.
    Thanks very much.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Refreshing data in listbox on userform fires it's afterupdate event a second time

    Hi and welcome to the forum

    Quote Originally Posted by progom View Post
    On clicking on a listbox line item - the listbox_afterupdate event fires
    Not sure I follow what you are doing.
    Clicking an item in a listbox doesn't trigger its own AfterUpdate event.
    Why are you using the AfterUpdate procedure to update instead of the Click event procedure?

    If you must use the AfterUpdate procedure to update the listbox and only want it to trigger once, you could toggle a Boolean variable and wrap the code in an IF code block so the 2nd time it runs, the update part of the code is ignored. Something like this...
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    09-24-2016
    Location
    SoCal
    MS-Off Ver
    2013
    Posts
    2

    Re: Refreshing data in listbox on userform fires it's afterupdate event a second time

    AlphaFrog: Click event works great. I knew I was making some simple mistake but couldn't see through the fog.

    I appreciate your help.

    progom

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Userform runs Initialize sub @ beginning of textbox AfterUpdate event w/out being called
    By chirp08 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-18-2016, 01:02 PM
  2. VBA refreshing listbox in userform
    By devatu in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 08-12-2015, 04:16 AM
  3. Exiting Excel fires Change Event on ListBox
    By 24601 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-18-2014, 01:14 PM
  4. Userform textbox event that fires after I exit the textbox
    By jerseyguy1996 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-04-2010, 08:08 AM
  5. Refreshing a userform/listbox
    By toocold in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-03-2006, 04:10 PM
  6. [SOLVED] PivotField AfterUpdate event?
    By Snowsride in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-11-2006, 09:15 AM
  7. AfterUpdate Event not Running
    By Craig in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-06-2005, 06:35 PM

Tags for this Thread

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