+ Reply to Thread
Results 1 to 11 of 11

Error Updating Listbox

  1. #1
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Error Updating Listbox

    Hello gents,

    Im having some problems when updating my listbox cause when I do so, all the data repeats and repeats on each click I do on the "Update boton"
    I have attached the file Im working on.
    If you just run the userform and click the boton "Update", you will see how the listbox copy twice all the values.

    Could someone help me on this?

    I really apreciate the help

    Thanks, regards
    Attached Files Attached Files
    Last edited by pezalmendra; 08-18-2012 at 03:51 PM.

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: Error Updating Listbox

    Good evening pezalmedra

    Quote Originally Posted by pezalmendra View Post
    If you just run the userform and click the boton "Update", you will see how the listbox copy twice all the values.
    I couldn't see an "Update" button on any of the forms.
    However, you can use a clear instruction, before repopulating your list box, thus :
    Please Login or Register  to view this content.
    HTH

    DominicB

  3. #3
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Error Updating Listbox

    I couldn't figure out where the problem is, so I will speak in general. If you have an event that adds items to the list box, perhaps you should first delete the listbox, then run the code. Just a simple example:

    Please Login or Register  to view this content.
    If you need more help, can you point me exactly where your code is to load the listbox and I will try and help?

  4. #4
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Error Updating Listbox

    Hi,

    I attach the new file.

    If you press the "Run" botton the userform will pop up. After that try this:

    - Press Edit botton
    - Change any value from a textbox
    - Press Update

    You will see how all the lines that where already on the listbox appears again underneath of the old ones. This occurs each time you press Update.

    Thanks a lot for your attention. I appreciate it

    Regards
    Attached Files Attached Files

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Error Updating Listbox

    I think BigBas is right

    try this
    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  6. #6
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Error Updating Listbox

    Excellent!!! Like always, thanks a lot guys


  7. #7
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Error Updating Listbox

    Oops sorry once again... just something I have noticed that I didnt realize it was happening:

    Each time I press the boton "Insert Trip", a new trip starts in the UserForm and its to be filled in. Once you have introduced the information in the textboxes you want you then press "Update" and the data is stored in the Listbox. Everything OK up to here.

    The problem comes when you delete all the trips from the ExcelSheet "Hoja1" and you start from the beggining inserting data through the userform.

    I have attached 2 files:
    - One of them if data already stored (works perfect)
    - One with no data stored (doesnt work)

    Thanks again, I appreciate the time you are taking on this.

    pezalmendra
    Attached Files Attached Files
    Last edited by pezalmendra; 08-19-2012 at 02:29 PM.

  8. #8
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Error Updating Listbox

    Hi!

    Any idea about it?

    Regards,

  9. #9
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Error Updating Listbox

    Hi Pezal,

    I took a look at the code, and although I'm not 100% sure what I was doing, I think that I identified the problem. The code that you were using to identify the last row of data would not work if there is not data. It wasn't throwing an error, but it was not effective. I modified the Nuevo_Click code to check if there exists any data. If not, it sets the code to 1, otherwise, it adds on. Try replacing your Nuevo_Click code with the following and let me know if it works.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    07-22-2012
    Location
    Spain
    MS-Off Ver
    Excel 2008
    Posts
    304

    Re: Error Updating Listbox

    Bas youre a genius!!

    Its working as I wanted to!!!
    Thanks a lot like always! I really appreciate all this help.

    How do I put a star on this?

    Regards!

  11. #11
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Error Updating Listbox

    Great! I'm glad it worked

+ 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