Listbox selected freezes the form

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
 
S

Stuart McCall

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)
 
L

Linq Adams via AccessMonster.com

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.
 
S

ShariS

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)
 

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