+ Reply to Thread
Results 1 to 9 of 9

ListBox_AfterUpdate proceedure causing loop

  1. #1
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    ListBox_AfterUpdate proceedure causing loop

    Dear members,
    I am still stuck on my continuous loop problem.
    The folowing code causes the trouble. As soon as an order is selected in ListBox1 The proceedure goes into a loop as if the ListBox is continualy being updated. I have used this technique before without problem, but can't see what I am doing differently. Help would be greatly appreciated.
    I have attached an extract drom the workbook in case that helps. The password is "magpie"

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by j_Southern; 05-03-2011 at 07:16 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: ListBox_AfterUpdate proceedure causing loop

    Please Login or Register  to view this content.



  3. #3
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: ListBox_AfterUpdate proceedure causing loop

    snb
    Thanks a lot for your reply.
    Although your code is much neater than mine, I cant see any difference in principle. I will try it anyway and let you know how I get on.
    John

  4. #4
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: ListBox_AfterUpdate proceedure causing loop

    sbn
    I have tried your code but I still get caught in the loop. If I put in a code line such as STOP or a MsgBox then the code (yours and mine) works and the text boxes are populated. However it should work in such a way that as soon as I highlight the ListBox1 value, the Form is populated, and if I change the ListBox1 value, the form should repopulate with new values. I have similar code doing this job on other projects, and I cannot see why it doesn't work on this one.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: ListBox_AfterUpdate proceedure causing loop

    Please Login or Register  to view this content.
    But is much simpler to read into listbox1 all the possible values:

    Please Login or Register  to view this content.
    and use this code on listbox1_change
    Please Login or Register  to view this content.
    Last edited by snb; 04-27-2011 at 11:44 AM.

  6. #6
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: ListBox_AfterUpdate proceedure causing loop

    snb
    I am gob smacked that you have put so much effort into solving my problem. Thank you so much.
    I understand that you are suggesting I use the _Change rather than _Update event. The use of list and listindex is new to me so it will take a little while for me to understand it, but I am certainly going to try, and will let you know how I fare
    Regards
    John

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: ListBox_AfterUpdate proceedure causing loop

    I will monitor your progress....

  8. #8
    Valued Forum Contributor
    Join Date
    09-21-2003
    Location
    British Columbia , Canada
    MS-Off Ver
    03,07,10,13
    Posts
    727

    Re: ListBox_AfterUpdate proceedure causing loop

    The original looping error was caused by the line ".ListBox1.BoundColumn = 1" if you delete that line you can get your OrderNo by ...

    OrderNo = .ListBox1.Column(0, .ListBox1.ListIndex)

    .. and then the loop issue will stop happening.

  9. #9
    Forum Contributor
    Join Date
    03-30-2010
    Location
    Manchester England
    MS-Off Ver
    Excel 2010
    Posts
    992

    Re: ListBox_AfterUpdate proceedure causing loop

    snb,
    The list listindex method worked perfectly thank you. I shall use it in future it saves a lot of coding.

    nimrod,
    Thank you too for your contribution. Your solution ties in well with the above.

+ 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