i have a userform with two listboxes, and six optionbuttions. the
options buttons are split into 3 pairs of two. at the outset only the
first pair of option buttons is enabled. the following code tests to
see if more than one selection is made in a listbox, and if it is, then
enables a relevant pair of option buttons.

Private Sub Listbox1_change()
'check to see if there is a multiple selection
Dim i As Integer
Dim Acount As Integer
Acount = 0

With Userform1.Listbox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
Acount = Acount + 1
End If
Next i
End With
If Acount > 1 Then
Userform1.OptionButton5.Enabled = True
Userform1.OptionButton6.Enabled = True
End If
Userform1.Repaint
End Sub

this code works fine, when i run the code, by stepping through it. In
fact i don't need the Userform1.Repaint line, when i run it this way.
But the appearance of the userform doesn't change when i run the code
normally. Is there some other trick to getting this change to happen?

thanks for your help.

Re: enable option buttons at runtime by Doug

Doug
Thu Feb 16 13:44:43 CST 2006

Your code should work IF the form is still called UserForm1. Did you change
the name of it. Actually however, it is not necessary to preface the names
of the controls with the name of the userform if the code is in the form.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"natanz" <natan.zimand@gmail.com> wrote in message
news:1140045122.139633.178500@z14g2000cwz.googlegroups.com...
>i have a userform with two listboxes, and six optionbuttions. the
> options buttons are split into 3 pairs of two. at the outset only the
> first pair of option buttons is enabled. the following code tests to
> see if more than one selection is made in a listbox, and if it is, then
> enables a relevant pair of option buttons.
>
> Private Sub Listbox1_change()
> 'check to see if there is a multiple selection
> Dim i As Integer
> Dim Acount As Integer
> Acount = 0
>
> With Userform1.Listbox1
> For i = 0 To .ListCount - 1
> If .Selected(i) Then
> Acount = Acount + 1
> End If
> Next i
> End With
> If Acount > 1 Then
> Userform1.OptionButton5.Enabled = True
> Userform1.OptionButton6.Enabled = True
> End If
> Userform1.Repaint
> End Sub
>
> this code works fine, when i run the code, by stepping through it. In
> fact i don't need the Userform1.Repaint line, when i run it this way.
> But the appearance of the userform doesn't change when i run the code
> normally. Is there some other trick to getting this change to happen?
>
> thanks for your help.
>



Re: enable option buttons at runtime by natanz

natanz
Thu Feb 16 14:57:08 CST 2006

the names are consistent. in fact i know it does work, as i say, when
i step through it, but not when i run it. I am guessing that there is
some timing issue.

can i email you the actual file?


Re: enable option buttons at runtime by Doug

Doug
Thu Feb 16 15:42:07 CST 2006

I doubt that it is a timing issue, but email me the file and I will look at
it.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"natanz" <natan.zimand@gmail.com> wrote in message
news:1140123428.797161.143250@g44g2000cwa.googlegroups.com...
> the names are consistent. in fact i know it does work, as i say, when
> i step through it, but not when i run it. I am guessing that there is
> some timing issue.
>
> can i email you the actual file?
>



Re: enable option buttons at runtime by natanz

natanz
Thu Feb 16 19:57:22 CST 2006

i have sent you two versions of the file. please use the second file.
it has an annoying msgbox, but it is illustrative of the problem i am
having.