Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing listbox selection in listbox AfterUpdate event

Status
Not open for further replies.

marle35

Programmer
Jul 17, 2007
36
I am using Access 2000. I have a single-selection listbox in a form, and I am able to access the selected value, but only at a later point like when a button is pressed. In the the AfterUpdate event for the listbox, the event fires but when I try to access the selected value, I get "Run-time error 2480: you referred to a property by a numeric argument that isn't one of the property numbers in the collection." I need to access the value when the item is selected, it's highly important. This code gives the basic idea:

Private Sub lstType_AfterUpdate()
MsgBox (lstType.ItemData(lstType.ItemsSelected(0)))
End Sub

What might be going wrong?
 
The selected value in a single selection listbox is the value of the listbox:
[tt]Me.lstType[/tt]

Or, if you insist:
[tt]Me.lstType.Value[/tt]

It is available in the click event.
 
Thanks, what threw me off was my original way was accessing the value in other procedures.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top