Solved

Simple multicolumn combobox in vba

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
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…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

895 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

12 Experts available now in Live!

Get 1:1 Help Now