Strange Listbox Behavior

Moniker

VBA Pro
Local time
Today, 17:32
Joined
Dec 21, 2006
Messages
1,567
I'm not sure there's an answer to this (I think it's a bug in Access), but I'll go fishing for an answer for a change. ;) I'm going to have to be generic as the programming I do is of a confedential nature, but I think I can handle this.

I have a form with listbox (amongst many other controls). This listbox is populated by a SQL statement in the RowSource property. It has seven columns, three of which are visible. The BoundColumn is not one of the visible rows. There are approximately 100 rows in the listbox, with around 10 or so visible at any given time.

When the form is first loaded, the vertical scrollbar works as it should, allowing you to scroll up and down through the rows. By using other controls on the form, you can alter the contents of the listbox. This happens dynamically and all works as it should as this isn't a difficult thing to do. However, that is not the issue.

After opening the form and making a change to the contents of the listbox by using the other controls, the vertical scrollbar still works. When you switch to form design mode, and then switch back to form view, the vertical scrollbar will no longer work. I've attempted a lot of different ways to get this scrollbar to work, including Me.Refresh, requerying the listbox (which already happens to display the data changes), Me.Repaint (which shouldn't affect the functionality of an object, but I was running out of ideas), and even a DoEvents. None of these restored the vertical scrollbar functionality.

I discovered two ways to make the scrollbar work again:

1) Close the form completely (not just to design view, but actually close it), and then reopen it and the vertical scrollbar works again.

2) Give another object besides the form the focus, and then give the focus back to the form, and the vertical scrollbar automagically works again. You can do this by clicking on the database window, going to the code window, etc. Just having the form itself lose focus and then regain focus restores the vertical scrollbar.

This is a pretty minor issue in the long run as the form is still functional (you can use the arrow keys, the mouse wheel, and page up/down to scroll through the listbox), but it's annoying the hell out of me. Additionally, this listbox could potentially contain several hundred entries, making the keyboard and/or mouse wheel scrolling tedious at best.

Have I come across a bug in the listbox control, or is there a workaround for this? I guess the strangest part was that setting the focus to something else -- pretty much anything else -- and then returning the focus to the form with the listbox control restored the scrollbar functionality.

I know I can just make a hidden form, throw the focus to that form for a flash, and then bring it back to my main form, but that seems rather silly. Again, I think I've uncovered a bug in the control, but if I haven't, I'd love to hear a rational explanation for this strange object behavior.

Thanks and sorry about the long read. :)
 
The plot thickens

Well, crap.

My boss and I just spent an hour on the phone trying to track this down. In fact, he can't recreate it on his machine. I considered that on the way home, thinking that my work machine may not be as up-to-date as my home computer. However, both my work and my home computers exhibit the issue. My boss's magic laptop doesn't.

Anyway, we went through the legendary "walk the data" replacing "data" with "code". We stripped out all references to the listboxes, then stripped out all the code from the form, and it still exhibited the strange behavior. We then made a new DB, added a form with just a listbox, made it a value list (1-15) and the scrollbar didn't work at all for me. WTF is right.

At the same time, I was recreating these same things on a Windows Vista machine with Office 2007 Professional, and that exhibited none of the issues.

My boss was initially thinking that it might be somehow related to video drivers. My home computers have very high-end video cards in them (the drivers are around 30MB), but my work machine has built-in crap video with minimal drivers. However, a laptop will have a completely different set of drivers, so that may be an issue after all. I don't know why a video driver would control the behavior of an object in Access, but at this point, I'm not ruling anything out.

I updated my Office 2003 Pro and Windows XP to the latest everything, and well, no dice. There's not a lot I can think of here since my boss couldn't recreate the error on his end (although he saw it on my work machine). We walked through each process to recreate the error, step-by-step. I would get the bug, he wouldn't. If anyone can explain this (or if I come across a reasonable explanation), please share.

Finally, understand that my boss and I are very close to the same skill level when it comes to programming -- we've both been doing this for 20+ years. When we're out of ideas, we've either found a very weird anomaly in Access, or we've overlooked something very obvious.
 
Hi Moniker,

Here is a Link to a similar problem with combobox.

This might give an idea of what is the problem.

snip
I'm not sure there's an answer to this (I think it's a bug in Access), but I'll go fishing for an answer for a change. ;) I'm going to have to be generic as the programming I do is of a confedential nature, but I think I can handle this.
Thanks and sorry about the long read. :)
 

Users who are viewing this thread

Back
Top Bottom