I have two combo boxes on a form, the second one is dependent upon what is
in the first as to what list it shows.
I have found a bit of code from Jay Freedman using array (message dated 14
August) and this works. Here is some of it:
Select Case ComboBox1.Text
Case ³Cat²
With ComboBox2
.clear
.list = Array (³Purr², ³Meow², ³Catnip²)
.listIndex = 0
End with
The problem is that I already have my code for combo box 2 set up as
.additem and there are over 70 items. Each .additem is a sentence, not a
single word.
How do I change the array to a list so I can use this code?
Many thanks
Sol
Sol Apache - 11 Dec 2006 01:54 GMT
I forgot to mention that one array has 51 items in it and VB refuses to have
this, saying it is too long as an array. The 51 item list works fine as an
.additem list when I do not have it referring to a selected item of another
combo box.
On 10/12/06 23:45, in article C1A24C84.4E9D%Sol@solapache.com, "Sol Apache"
<Sol@solapache.com> wrote:
> I have two combo boxes on a form, the second one is dependent upon what is
> in the first as to what list it shows.
[quoted text clipped - 23 lines]
>
> Sol
Sol Apache - 11 Dec 2006 02:09 GMT
Well, amazingly, I have figured it out myself. The code is:
Case ³Cat2²
With cmbList
.clear
End with
Cmblist.AddItem ³meaow²
Cmblist.Additem ³meaow2²
And so forth.
On 10/12/06 23:45, in article C1A24C84.4E9D%Sol@solapache.com, "Sol Apache"
<Sol@solapache.com> wrote:
> I have two combo boxes on a form, the second one is dependent upon what is
> in the first as to what list it shows.
[quoted text clipped - 23 lines]
>
> Sol
Jay Freedman - 11 Dec 2006 02:48 GMT
Good, you're doing well with this.
The next step is to clean it up a bit. The purpose of the "With
cmbList" statement is to let you avoid repeating "cmbList" for each
statement up to the End With. That is, the dot (such as the one before
"Clear") is understood to refer to the object in the With statement.
So your code should be
Case "Cat2"
With cmbList
.Clear
.AddItem "meaow"
.Additem "meaow2"
End with
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
>Well, amazingly, I have figured it out myself. The code is:
>
[quoted text clipped - 36 lines]
>>
>> Sol