[AccessD] Form hangs when setting listbox selected index

Steve Schapel miscellany at mvps.org
Tue Jun 12 20:14:11 CDT 2007


Chris,

I have been discussing this in a private forum with Stephen Lebans, and 
he gave me permission to reproduce some of his comments...

"I have worked with the Listbox control in a form's Load event 
extensively for several of my projects. It appears the control is not 
fully instantiated even in the Load event let alone the earlier Open 
event. The control's Window is created early in the process but as you 
stated, not all of the control's properties are available until the Load 
event (and some of them are still not available in the Load event).

UI interaction, for example, setting Focus to the control or causing a 
redraw of the control, will fail in the Open event, and sometimes even 
fail in the Load event. It seems to be dependant on the version of 
Access you are
using, whether your form contains a Subform control, etc.."

And as for the reason why
Me.NameOfListbox = Me.NameOfListbox.ItemData(0)
... works on the Open event, where the Selected(n) property doesn't... 
the ItemData collection does not require a redraw of the control, where 
Selected does.

Hope that helps.

Regards
Steve

Christopher Jeris wrote:
> Setting the selected item in the Load event, rather than the Open event,
> seems superficially to work; but why should that be?  I'm reluctant to
> trust it without understanding the reason for this behavior.



More information about the AccessD mailing list