Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
KnooKie
Aged Yak Warrior
623 Posts |
Posted - 2002-05-23 : 06:07:10
|
Is there an easy way of unselecting an item in a list box using VBA ??Is there a way of unselecting without having to loop through the whole list and use the select property ?? I assume that will do it.thanksPaulPaul |
|
KnooKie
Aged Yak Warrior
623 Posts |
Posted - 2002-05-23 : 06:55:21
|
answer...... Dim intCurrentRow As Integer For intCurrentRow = 0 To lst.ListCount - 1 If lst.Selected(intCurrentRow) = True Then lst.Selected(intCurrentRow) = False Exit For End If Next intCurrentRowPaul |
 |
|
KnooKie
Aged Yak Warrior
623 Posts |
Posted - 2002-05-23 : 08:53:11
|
Although the above code works i was unable to write it as a Global Module passing in the form and listbox name. If anyone has any ideas that'd be great.Paul |
 |
|
RatTail
Crackhead
98 Posts |
Posted - 2002-05-24 : 12:25:43
|
Hi, KnooKie!Try as following:' global functionFunction WhatYouNeed(ByVal NameOfForm As String)Dim iDoCmd.OpenForm NameOfForm, acNormalFor Each i In Screen.ActiveForm.NameOfListBox.ItemsSelected................................................NextEnd Function |
 |
|
RatTail
Crackhead
98 Posts |
Posted - 2002-05-24 : 15:28:46
|
forgot the second parameter: listbox's nameFunction WYN(ByVal fn, lbn)Dim iDoCmd.OpenForm fn, acNormalScreen.ActiveForm.Controls(lbn).SetFocusFor Each i In Screen.ActiveControl.ItemsSelected................................................ Next End Function |
 |
|
RatTail
Crackhead
98 Posts |
Posted - 2002-05-25 : 07:06:06
|
forgot: to avoid looping thru all rows of the listbox use:For Each i In Screen.ActiveControl.ItemsSelectedScreen.ActiveControl.Selected(i) = FalseNextBelieve that's all you need. |
 |
|
KnooKie
Aged Yak Warrior
623 Posts |
Posted - 2002-05-27 : 07:39:21
|
Many ThanksI will give it a goPaul |
 |
|
|
|
|