Solved

Setting the value of a combo box

Posted on 2003-11-20
7
311 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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 250 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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