Solved

Add a combo box to a toolbar and reference the selection

Posted on 2008-10-23
4
349 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

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…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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.

809 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