Listbox not refreshing on update

G

Guest

Hi There,

I have a form with a multicolumn listbox and text boxes corresponding to the
columns of the listbox. I also have 'Insert', 'Update' & 'Delete' buttons
that are used to maintain the list in conjunction with the textboxes. I am
using the listbox_Change event to keep the textboxes and listbox synchronized.

My issue is this: when I insert new items into the listbox it doesn't always
display the list correctly. Suppose the list currently has "Item1, ...,
Item5, Item7". I will insert 'Item6', the listboxes will display Item6 but
the list will show two of Item7. If I scroll through the items in the
listbox, it will correctly display the list items in the textboxes; but, the
listbox will continue to show two of Item7. If I continue to scroll up and
down through the list, the listbox will eventually 'refresh'(?) and start to
show the correct list.

What gets me is that internally the list is clearly OK as scrolling through
the list always generates the correct values being displayed in the
textboxes. It's as if the listbox control needs some time before the
'displayed' list matches the 'internal' list.

Any thoughts, suggestions would be greatly appreciated!
Thanks,
tdw

--
Timothy White
Contract Programmer
Ontario, Canada

<my initials>hite<at>sympatico<dot><countryCode>
 
L

Leith Ross

Hello Tim,

Try adding Repaint into the update code.

UserForm1.Repaint

This should solve the problem. Change UserForm1 to match your Form's
anme.

Sincerely,
Leith Ross
 
G

Guest

Hi Leith,

Thanks for the suggestion!

Unfortunately, that doesn't work. At some point (it doesn't happen every
insert and I haven't yet noticed a pattern when it does happen) when I insert
into the list I still see a duplicate item in the list box; but, the correct
list of unique items in the text boxes. If I scroll the list box a couple of
times it seems to sort itself out and begin to show the correct list; but,
again, it isn't always immediate.

My biggest fear with using the Repaint was that the form would flash.
Fortunately, that doesn't appear to be the case. I just wish the listbox
would refresh
--
Timothy White
Contract Programmer
Ontario, Canada

<my initials>hite<at>sympatico<dot><countryCode>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top