Solved

Simple multicolumn combobox in vba

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

832 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