Listbox selected freezes the form

  • Thread starter Thread starter ShariS
  • Start date Start date
S

ShariS

I'm using the following line in the form_open to select the first item in the
list which susequently selects data in the second listbox:

Me.lstDate.Selected(0) = True

However the whole form freezes and nothing works? Any ideas?

Many thanks

ShariS
 
ShariS said:
I'm using the following line in the form_open to select the first item in
the
list which susequently selects data in the second listbox:

Me.lstDate.Selected(0) = True

However the whole form freezes and nothing works? Any ideas?

Many thanks

ShariS

That code will only work if the listbox's multiselect property is set to
simple or extended. If it is set to none, replace the code with this:

Me.lstDate = Me.lstDate.ItemData(0)
 
Why do you need to use code to select the first item in a listbox when the
form first opens? Wouldn't this item normally appear first?

You sound like you're using cascading listboxes. This is usually done by
setting the RowSource in the 2nd box in the AfterUpdate event of the 1st box.

Setting the value of the 1st listbox in code won't accomplish this, because
the AfterUpdate event will only fire if the selection of the item in the
listbox is made by the user actually clicking on an item, not by assigning it
in code.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
Thanks for this, it did the trick.

Many thanks

ShariS

Stuart said:
I'm using the following line in the form_open to select the first item in
the
[quoted text clipped - 7 lines]

That code will only work if the listbox's multiselect property is set to
simple or extended. If it is set to none, replace the code with this:

Me.lstDate = Me.lstDate.ItemData(0)
 
Back
Top