tags:

views:

61

answers:

2

how do i msgbox the first entry in a listbox in ms-access with vba?

+1  A: 

Using MS Access 2007 you can try

MsgBox YourListBox.ItemData(0)
astander
when i do this, the whole form freezes up for some reason
I__
What is the datasource to the Listbox, and did you try stepping throught the code?
astander
as you know the debugger in access isnt so powerful you can't step through
I__
+6  A: 

Is the item selected in a simple list box (that is, not multi-select)? If so:

MsgBox  Me.ListBox

Is it a selected item in a multi-select list box? if so:

MsgBox Me.ListBox .Column(0, Me.List0.ItemsSelected(0))

If you simply want the first item whether or not it is selected:

MsgBox Me.List0.Column(0, 0)

Or

MsgBox Me.List0.ItemData(0)
Remou