473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Adding a combobox control to a shortcut menu

I need a right-click menu on a form list control with combobox
controls.

I used View->Toolbars->Customize to create a toolbar.
I added ComboBox through commands tab.
I set properties to Popup making it a shortcut menu.

I have no problem linking it to the list control.

The menu comes up when I right-click the list control.

I have no problem running an OnAction event when an item is selected on
the menu.

However, when I select a menu item and the OnAction fires, I get an
error saying I have a type mismatch which tags the line:

Set mycontrol = mybar.Controls("Position").
Here's the whole VBA function:
Public Function SeatmeatPosition()

Dim mybar As CommandBar, mycontrol As CommandBarComboBox
Dim dbs As Database, rst As Recordset, intI As Integer

Set mybar = CommandBars("TestSeatmeatPopup")
Set mycontrol = mybar.Controls("Position")

Set rst = CurrentDb.OpenRecordset("SELECT Position.RefId,
Position.Title FROM [Position] order by Position.RefId DESC")
rst.MoveFirst
intI = 1

' Fill combo box with crew position titles
While Not rst.EOF
With mycontrol
.AddItem Text:=rst!Title, Index:=intI
End With
intI = intI + 1
rst.MoveNext
Wend

' Set combo box properties
With mycontrol
.Caption = "Position"
.Width = 200
.DropDownLines = 10
.DropDownWidth = 300
' This is the function called when an item is
' selected from the list.
.OnAction = "=ShowCustomerInfo()"

End With
End Function

If I change the mycontrol definiton to: mycontrol As CommandBarButton
it gets past that line, but hangs on AddItem. That's of course
expected since AddItem isn't part of CommandBarButton.

So, how do I get a working combo box on a right-click shortcut menu
which use AddItem to add items from a selected table?

Aug 18 '06 #1
1 4429
Well, closer...

I changed the VBA from this:

Set mycontrol = mybar.Controls("Position")

to this:

Set mycontrol = mybar.Controls.Add(Type:=msoControlComboBox)

It adds a combo box, gets input from the table and adds the items.

Problem, is now that it does this every time I click on the Postion
menu item of my menu. I have multiple drop downs and a new one every
time I use the menu.
Of course, this is what I told the VBA to do.

So how do I get what I really want? A combo box labeled "Position"
with drop down items from the table. And just one combo box!
st**********@excite.com wrote:
I need a right-click menu on a form list control with combobox
controls.

I used View->Toolbars->Customize to create a toolbar.
I added ComboBox through commands tab.
I set properties to Popup making it a shortcut menu.

I have no problem linking it to the list control.

The menu comes up when I right-click the list control.

I have no problem running an OnAction event when an item is selected on
the menu.

However, when I select a menu item and the OnAction fires, I get an
error saying I have a type mismatch which tags the line:

Set mycontrol = mybar.Controls("Position").
Here's the whole VBA function:
Public Function SeatmeatPosition()

Dim mybar As CommandBar, mycontrol As CommandBarComboBox
Dim dbs As Database, rst As Recordset, intI As Integer

Set mybar = CommandBars("TestSeatmeatPopup")
Set mycontrol = mybar.Controls("Position")

Set rst = CurrentDb.OpenRecordset("SELECT Position.RefId,
Position.Title FROM [Position] order by Position.RefId DESC")
rst.MoveFirst
intI = 1

' Fill combo box with crew position titles
While Not rst.EOF
With mycontrol
.AddItem Text:=rst!Title, Index:=intI
End With
intI = intI + 1
rst.MoveNext
Wend

' Set combo box properties
With mycontrol
.Caption = "Position"
.Width = 200
.DropDownLines = 10
.DropDownWidth = 300
' This is the function called when an item is
' selected from the list.
.OnAction = "=ShowCustomerInfo()"

End With
End Function

If I change the mycontrol definiton to: mycontrol As CommandBarButton
it gets past that line, but hangs on AddItem. That's of course
expected since AddItem isn't part of CommandBarButton.

So, how do I get a working combo box on a right-click shortcut menu
which use AddItem to add items from a selected table?
Aug 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Steven | last post by:
I have some text boxes on a form in MS Access 2000. When I right click in them I don't get any shortcut menu at all. I want the normal cut, copy, and past menu to come up. In the "Startup", I...
0
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to...
4
by: Keith Smith | last post by:
I am reading this article... http://www.codeproject.com/cs/combobox/csautocomplete.asp About half-way down you will see a section titled "Using This Control" (written in orange lettering). ...
4
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create...
6
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for...
1
by: MarkusJ_NZ | last post by:
Hi, can someone please provide me with some information on how I can create a shortcut from the users start menu/ desktop to my installed application when I am using the VS2005 setup wizard. I...
8
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I created a user control that handles certain keystrokes, e.g. Ctrl-C for cut, Ctrl-V for paste, plus other more specialized keystrokes. I want to list these in the menubar like any other menu...
2
by: Andrus | last post by:
SWF DataGridView contains combobox control. Activating combobox and pressing F4 to open dropdown menu causes strange NRE (see below). When I enter some valid value to combobox, press tab,...
0
by: Jim Devenish | last post by:
I have successfully added shortcut menus to Forms but I am now having difficulty when I attach a shortcut menu to a text control. I have a shortcut menu entitled 'CalendarEntries' with one command...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.