Display Selected Item in a List Box

M

Melissa M

I have a listbox which whose datasource is a table with 52 records - one for
each week in the fiscal year. The form's OnOpen event triggers a procedure
which caculates the week # of the current date and selects that value in the
listbox. If the listbox's Multi Select property is set to 'None', the
selected value is shown; if Multi Select is either 'Simple' or 'Extended',
the listbox displays the values from the top of the list, not the selected
value.

How do I get it to display my selected value and have Multi Select cative?????
 
K

Klatuu

This routine will compare each row in the list, select the one the matches
your calculated week number and select it.

Dim lngX

For lngX = 0 to Me.MyListBox.ListCount -1
If Me.MyListBox.ItemData(lngX) = CalculatedWeekNumber Then
Me.MyListBox.Selected(lngX) = True
Exit For
End If
Next lngX
 
M

Melissa M

Selecting the value is not my problem - displaying it is. The list will only
display the first X number of list values, regardless of what the selected
value is.
 
K

Klatuu

Display it where?
You question, then is vague. Can you please describe in more detail what it
is you are trying to do?
 

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