Solved

Add a combo box to a toolbar and reference the selection

Posted on 2008-10-23
4
340 Views
Last Modified: 2010-04-21
Hi,

Is it possible to add a combo box to a custom toolbar if so how. I'll need to populate and extact the selection using VBA. I'm using Access 2003.
0
Comment
Question by:geraintcollins
  • 3
4 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 22794256
Dim newitem As Object
Set newitem = CommandBars("prTool").Controls.Add(Type:=msoControlComboBox)
CommandBars("prTool").Controls(1).AddItem "AAAAAA"
CommandBars("prTool").Controls(1).AddItem "BBBBBB"
CommandBars("prTool").Controls(1).AddItem "CCCCCC"
0
 
LVL 77

Expert Comment

by:peter57r
ID: 22794262
posted too early...
the code above adds a combo box with 3 options to a custom toolbar called prtool
0
 
LVL 77

Accepted Solution

by:
peter57r earned 125 total points
ID: 22794319
The only way I know to deal with the selection is to base the action on the listindex property...
Sub CBOAction()
Dim Sel As Long
Sel= CommandBars("prtool").Controls(1).ListIndex
    Select Case sel
        Case 1   'AAAAAA
            sub1
        Case 2   'BBBBBB
            sub2
        Case 3  'CCCCCC
            sub3
        Case Else
            MsgBox ("Invalid choice. Please choose again.")
    End Select
End Sub
0
 

Author Closing Comment

by:geraintcollins
ID: 31509472
Perfect, thanks Peter, the only thing I had to add was a reference to the microsoft office 11.0 object library as it wasn't happy with the control type.
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…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
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…

773 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