Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Setting the value of a combo box

Posted on 2003-11-20
7
Medium Priority
?
322 Views
Last Modified: 2010-05-01
I have a combo box (ListType) with the values:

ListType.additem ("1")
                              2
                              3
                              4
                              5
                              6

On_Load I want to set the value of the ComboBox

     ListType=3

then take the listindex of the combo box and set it equal to another combobox

     ListTypeF.ListIndex=ListType.ListIndex

How can I do this?

   - Marc
0
Comment
Question by:MarcGraff
[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
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9788256
Do you mean something like this?

Private Sub Form_Load()
With ListType
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

With ListTypeF
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

ListType.ListIndex = 2 ' to set to #3

ListTypeF.ListIndex = ListType.ListIndex


End Sub
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9788263
or maybe:

Private Sub Form_Load()
With ListType
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

ListType.Text = "3"

ListTypeF.Text = ListType.Text

End Sub
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9788313
My appologies, ListTypeF contains

     ListTypeF.additem "Stuff"
                                   "dshgaljsh"

are all all words... This is why I am trying to use there listindex.

   - Marc
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:MarcGraff
ID: 9788334
also ListType may have diffrent numbers in diffrent circumstances therefore I can not say .listindex=3 because sometimes that will give me a "2" and other times a "6"

Sorry,
   - Marc
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 9788425
How about:


Private Sub Form_Load()
Dim i As Integer

With ListType
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
End With

With ListTypeF
    .AddItem "Item1"
    .AddItem "Item2"
    .AddItem "Item3"
    .AddItem "Item4"
    .AddItem "Item5"
    .AddItem "Item6"
End With

ListType.Text = "3"

For i = 0 To ListType.ListCount - 1
    If ListType.List(i) = ListType.Text Then
        Exit For
    End If
Next i

ListTypeF.ListIndex = i


End Sub
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 1000 total points
ID: 9788449
You could also add this to the ListType's click event to have ListTypeF to change when listType is changed:

Private Sub ListType_Click()
Dim i As Integer
For i = 0 To ListType.ListCount - 1
    If ListType.List(i) = ListType.Text Then
        Exit For
    End If
Next i

ListTypeF.ListIndex = i
End Sub
0
 
LVL 1

Author Comment

by:MarcGraff
ID: 9788638
Sweet! Thanks so much!

   - Marc
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

598 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