+ Reply to Thread
Results 1 to 5 of 5

Listbox fails to update after deleting an item

  1. #1
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Listbox fails to update after deleting an item

    Hi,

    I've created a nifty userform listbox prototype that I'm about to use on a project and it's nearly complete except for 3 related bugs I need your help on.

    The first is the macro that deletes an item from the listbox and the underlying database (cmdDelete) causes the Listbox1_Click macro--and the userform--to blow up. cmdDelete completes successfully, but I'm guessing the Listbox macro is triggered and is looking for the deleted item and crashes the userform??? Which is tied to the second bug...

    I can't get the listbox to update after a record has been added or deleted so that the user can then continue manipulating the listbox items.

    And the last bug is that when the userform launches, I can't get the initialization to highlight that last record (item) clicked on (which is stored in cell A10).

    Lawrence
    Attached Files Attached Files
    Last edited by skysurfer; 08-09-2010 at 01:16 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Listbox fails to update after deleting an item

    You can't use RemoveItem unless the ListBox has been loaded using AddItem. Try
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: Listbox fails to update after deleting an item

    Hi Roy,

    Your code successfully deletes the record in the database and the listbox, but it triggers the Listbox1_Click macro and then crashes on this line:

    Please Login or Register  to view this content.
    Attached an updated file your your code.

    Thanks!

    Lawrence
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: Listbox fails to update after deleting an item

    Perhaps the initialize macro needs to refresh the listbox range???

    Lawrence

  5. #5
    Forum Contributor
    Join Date
    05-24-2006
    Location
    Los Angeles
    MS-Off Ver
    2019
    Posts
    328

    Re: Listbox fails to update after deleting an item

    Solution code:

    Please Login or Register  to view this content.

+ 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