Solved

ComboBox Help

Posted on 2004-10-11
4
211 Views
Last Modified: 2010-05-02
I'm using VBA.

I'm need to add the same data in to multiply comboboxes.  I'm using the .additem method.  is there an easier way to do this.

How would i go about using an array?
0
Comment
Question by:Jason_Kha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 9

Expert Comment

by:Shahid Thaika
ID: 12280110
Not sure about any other way to duplicate lists other than using AddItem(). But here is an example on how to duplicate a combo box. Same goes for other controls and the form. However, when a new combo box is duplicated from another combo box, its list will be empty.

First add a combo box to a form. Set its index property to 0. Since we want to start an array. Copy the code below.

Private Sub Command1_Click()
'Loads a new combo box in the memory. Index value will have to be one higher than the existing highest index
Load Combo1(Combo1.UBound + 1)
'Moving the combo box to a particular position on the form
Combo1(Combo1.UBound).Move Combo1.UBound * 10, Combo1.UBound * 10
'Making it visible on the form.
Combo1(Combo1.UBound).Visible = True
End Sub
0
 
LVL 8

Expert Comment

by:ampapa
ID: 12280164
Here is a general idea of loading the combo:

'Crerate the array
Dim MyWeek
MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")

'Clear the box before adding items
Form1.cmbday.Clear

'Add the new items
for x = 0 to ubound(MyWeek )
    'Add the item to the drop down
    Form1.cmbday.AddItem MyWeek (x)
next x


0
 
LVL 8

Accepted Solution

by:
ampapa earned 500 total points
ID: 12280186
Sorry about the double post I thought I would add something. In the sub below you could always just add your multiple comboboxes to fill:

'Add the new items
for x = 0 to ubound(MyWeek )
    'Add the item to the drop down
    Form1.cmbday1.AddItem MyWeek (x)
    Form1.cmbday2.AddItem MyWeek (x)
    Form1.cmbday3.AddItem MyWeek (x)
    ...
next x
0
 
LVL 8

Expert Comment

by:ampapa
ID: 12280431
Thanks for the grade. Glad I could help.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question