Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2006

Tip: Looking for answers? Try searching our database.

Combo box dual using .AddItem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sol Apache - 10 Dec 2006 23:45 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.