essaytee
Need a good one-liner.
- Local time
- Tomorrow, 08:50
- Joined
- Oct 20, 2008
- Messages
- 544
I've been researching how to implement the Right-Click menu in Access 2010. I came across an example from StackOverflow that partially works. I'm getting a Type Mismatch error on the following line:
When checking the debug session the value of msoControlButton = 1. I've checked my references and Microsoft Office 14.0 Object Library is checked and selected.
The line prior to the error occurring,
works.
The full function is here:
Any ideas please?
Steve.
Code:
Set combo = .Controls.Add(Type:=msoControlButton)
When checking the debug session the value of msoControlButton = 1. I've checked my references and Microsoft Office 14.0 Object Library is checked and selected.
The line prior to the error occurring,
Code:
Set combo = .Controls.Add(Type:=msoControlEdit)
The full function is here:
Code:
Public Sub SetUpContextMenu()
' Note: This requires a reference to Microsoft Office Object Library
Dim combo As CommandBarComboBox
' Since it may have been defined in the past, it should be deleted,
' or if it has not been defined in the past, the error should be ignored
On Error Resume Next
CommandBars("MyListControlContextMenu").Delete
On Error GoTo 0
' Make this menu a popup menu
With CommandBars.Add(Name:="MyListControlContextMenu", Position:=msoBarPopup)
' Provide the user the ability to input text using the msoControlEdit type
Set combo = .Controls.Add(Type:=msoControlEdit)
combo.Caption = "Lookup Text:" ' Add a label the user will see
combo.OnAction = "getText" ' Add the name of a function to call
' Provide the user the ability to click a menu option to execute a function
Set combo = .Controls.Add(Type:=msoControlButton)
combo.BeginGroup = True ' Add a line to separate above group
combo.Caption = "Lookup Details" ' Add label the user will see
combo.OnAction = "LookupDetailsFunction" ' Add the name of a function to call
' Provide the user the ability to click a menu option to execute a function
Set combo = .Controls.Add(Type:=msoControlButton)
combo.Caption = "Delete Record" ' Add a label the user will see
combo.OnAction = "DeleteRecordFunction" ' Add the name of the function to call
End With
End Sub
Any ideas please?
Steve.