PC Review


Reply
Thread Tools Rate Thread

disable entry on listbox

 
 
Smallweed
Guest
Posts: n/a
 
      22nd Oct 2008
Can I selectively disable an individual entry on a multiselect listbox in a
userform? If so, how?

Thanks
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      22nd Oct 2008
How about just not including it in the listbox to start--or removing it when it
shouldn't be selected?

Or even just ignore it if it is selected?

But if you want...

Option Explicit
Dim BlkProc As Boolean
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub CommandButton2_Click()
Dim iCtr As Long
With Me.ListBox1
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) = True Then
MsgBox iCtr & "--" & .List(iCtr)
End If
Next iCtr
End With
End Sub
Private Sub ListBox1_Change()

Dim ItemToBeAvoided As Long

If BlkProc = True Then
Exit Sub
End If

ItemToBeAvoided = 2 'third item (0 based)

If Me.ListBox1.Selected(ItemToBeAvoided) = True Then
BlkProc = True
Me.ListBox1.Selected(ItemToBeAvoided) = False
BlkProc = False
End If

End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
For iCtr = 1 To 5
.AddItem "A" & iCtr
Next iCtr
End With
End Sub

Smallweed wrote:
>
> Can I selectively disable an individual entry on a multiselect listbox in a
> userform? If so, how?
>
> Thanks


--

Dave Peterson
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Moving to an entry in a listbox John Spencer MVP Microsoft Access VBA Modules 2 21st May 2009 05:38 PM
Re: Moving to an entry in a listbox John Spencer MVP Microsoft Access VBA Modules 0 21st May 2009 03:29 PM
RE: Moving to an entry in a listbox Jack Leach Microsoft Access VBA Modules 0 21st May 2009 02:15 AM
Re: Moving to an entry in a listbox fredg Microsoft Access VBA Modules 0 21st May 2009 12:38 AM
Automatic new entry and disable old entry =?Utf-8?B?Si4gTWNHb25pZ2Fs?= Microsoft Access Forms 2 10th Feb 2006 03:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:56 AM.