By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,093 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,093 IT Pros & Developers. It's quick & easy.

Single selection in List Box

P: n/a


Ive a list box containing form names, and I want to return some property
details when an item on the list is selected
So far I've only been able to do this with the double click,
I wish to do this with only a single click, but when i do, I get an error

2480, ...............says the property is not in the collection.

Code below is for double click
This wont work for a single click

--------------------------------------------------
Private Sub List1_DblClick(Cancel As Integer)
On Error GoTo errroutine

Debug.Print Me.List1.Column(0, Me.List1.ItemsSelected(0))

Exit Sub

errroutine:
If err.Number = "3270" Then
Resume Next
Else
MsgBox err.Number & " " & err.Description
Exit Sub
End If

End Sub
-----------------------------------------------------
Any advice welcome.......
Gerry Abbott
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
If the ListBox's MultiSelect property is set to None, then just use the
AfterUpdate event.
(Assuming you are trying to return the bound column)

If Me!List1.ItemsSelected.Count <> 0 Then Debug.Print Me.List1

Mike Storr
www.veraccess.com
"Gerry Abbott" <pl****@ask.ie> wrote in message
news:oZ***************@news.indigo.ie...


Ive a list box containing form names, and I want to return some property
details when an item on the list is selected
So far I've only been able to do this with the double click,
I wish to do this with only a single click, but when i do, I get an error

2480, ...............says the property is not in the collection.

Code below is for double click
This wont work for a single click

--------------------------------------------------
Private Sub List1_DblClick(Cancel As Integer)
On Error GoTo errroutine

Debug.Print Me.List1.Column(0, Me.List1.ItemsSelected(0))

Exit Sub

errroutine:
If err.Number = "3270" Then
Resume Next
Else
MsgBox err.Number & " " & err.Description
Exit Sub
End If

End Sub
-----------------------------------------------------
Any advice welcome.......
Gerry Abbott

Nov 12 '05 #2

P: n/a
Thanks Mike,
However I did try the code with the AfterUpdate event, and the scrolling of
records does return the correct values,
but simply clicking on the list does not.

The multiselect property is none and ive tried this with your suggested
code, and I get the same effect.

Any other suggestions welcome
BTW, its office97,
Have not tried it on 2000/XP yet.


"Mike Storr" <st******@sympatico.ca> wrote in message
news:a5********************@news20.bellglobal.com. ..
If the ListBox's MultiSelect property is set to None, then just use the
AfterUpdate event.
(Assuming you are trying to return the bound column)

If Me!List1.ItemsSelected.Count <> 0 Then Debug.Print Me.List1

Mike Storr
www.veraccess.com
"Gerry Abbott" <pl****@ask.ie> wrote in message
news:oZ***************@news.indigo.ie...


Ive a list box containing form names, and I want to return some property
details when an item on the list is selected
So far I've only been able to do this with the double click,
I wish to do this with only a single click, but when i do, I get an error
2480, ...............says the property is not in the collection.

Code below is for double click
This wont work for a single click

--------------------------------------------------
Private Sub List1_DblClick(Cancel As Integer)
On Error GoTo errroutine

Debug.Print Me.List1.Column(0, Me.List1.ItemsSelected(0))

Exit Sub

errroutine:
If err.Number = "3270" Then
Resume Next
Else
MsgBox err.Number & " " & err.Description
Exit Sub
End If

End Sub
-----------------------------------------------------
Any advice welcome.......
Gerry Abbott


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.