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

x
?
Solved

Simple multicolumn combobox in vba

Posted on 2013-02-06
4
Medium Priority
?
545 Views
Last Modified: 2013-02-06
Hi

I would like to create a combobox  with two columns.  I would like the combobox to show the following information over two columns.  I would appreciate help.

A      Text 1
B      Text 2
C      Text 3

I've started with the code below,  but am unsure on how to get the data in there.

With Cmbo_ChooseCommand
        .ColumnCount = 2: .BoundColumn = 1:      .ColumnWidths = "6 cm;0;6 cm"


end with
0
Comment
Question by:peispud
[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
  • 2
  • 2
4 Comments
 
LVL 48

Expert Comment

by:Dale Fye
ID: 38862308
The combo box will only display one column at a time, until you drop it down, at which point you may see more than one, depending on the column width settings for your combo.

You do not need to do this in code.  Open you form in design view and drop the combo box onto the form.  Then set the ColumnCount, BoundColumn, and Column Values in the properties dialog box.

Then set the RowSourceType to "Value List" and enter the following in the RowSource field:

"A"; "Text 1"; "B"; "Text 2", "C"; "Text 3"
0
 

Author Comment

by:peispud
ID: 38862320
I would prefer to have this in code though.    I would appreciate that.
0
 
LVL 48

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 38862358
Why?

Private Sub Form_Load()

    With Me.comboTest
        .ColumnCount = 2
        .BoundColumn = 1
        .ColumnWidths = ".6cm;.6cm"
        .RowSourceType = "Value List"
        .RowSource = "A;Text 1;B;Text 2;C;Text 3"
    End With
   
End Sub
0
 

Author Closing Comment

by:peispud
ID: 38862373
Perfect.   Thanks!!

I had wanted it in code because for me,  it makes it easier to understand my code later.

Thank you!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

604 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