Solved

Simple multicolumn combobox in vba

Posted on 2013-02-06
4
537 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

831 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