Solved

Simple multicolumn combobox in vba

Posted on 2013-02-06
4
531 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
  • 2
  • 2
4 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now