Solved

Add a combo box to a toolbar and reference the selection

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
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…

743 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

11 Experts available now in Live!

Get 1:1 Help Now