Question : How do I programically select an item in a list box

On a Form I have a Tree View(product) and a List Box(item). When a selection in the Tree View is made the List Box is filled. The List Box has multiple columns and when an item is selected by the operator I use the code below to place the item into a global variable. How can I do this through programing if there is only 1 item in the list box?



Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
'check to see that a product and item selection has been made
If Not IsNull(selectedProductCode) Then
If Not IsNull(Me.ListItem.Value) Then

'save the Item code to global variables
selectedItemCode = Me.ListItem.Column(1)

'close window
DoCmd.Close
Exit Sub

Answer : How do I programically select an item in a list box

to select the first item in a listbox

me.listitem.value=me.listitem.itemdata(0)
Random Solutions  
 
programming4us programming4us