?
Solved

Add a combo box to a toolbar and reference the selection

Posted on 2008-10-23
4
Medium Priority
?
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

800 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