Как создать контекстное меню в ms-доступе? В контекстном меню я имею в виду, когда пользователь щелкает правой кнопкой мыши и появляется меню.Как создать контекстное меню в ms-доступе?
Ниже приведен код, который я написал для создания этого контекстного меню, но получаю сообщение об ошибке.
Ошибка компиляции: Пользовательский тип не определен
On Line: Dim cmbRightClick Как Office.CommandBar
Option Compare Database
Option Explicit
Sub CreateReportShortcutMenu()
Dim cmbRightClick As Office.CommandBar
Dim cmbControl As Office.CommandBarControl
' Create the shortcut menu.
Set cmbRightClick = CommandBars.Add("cmdReportRightClick", msoBarPopup, False, True)
With cmbRightClick
' Add the Print command.
Set cmbControl = .Controls.Add(msoControlButton, 2521, , , True)
' Change the caption displayed for the control.
cmbControl.Caption = "Quick Print"
' Add the Print command.
Set cmbControl = .Controls.Add(msoControlButton, 15948, , , True)
' Change the caption displayed for the control.
cmbControl.Caption = "Select Pages"
' Add the Page Setup... command.
Set cmbControl = .Controls.Add(msoControlButton, 247, , , True)
' Change the caption displayed for the control.
cmbControl.Caption = "Page Setup"
' Add the Mail Recipient (as Attachment)... command.
Set cmbControl = .Controls.Add(msoControlButton, 2188, , , True)
' Start a new group.
cmbControl.BeginGroup = True
' Change the caption displayed for the control.
cmbControl.Caption = "Email Report as an Attachment"
' Add the PDF or XPS command.
Set cmbControl = .Controls.Add(msoControlButton, 12499, , , True)
' Change the caption displayed for the control.
cmbControl.Caption = "Save as PDF/XPS"
' Add the Close command.
Set cmbControl = .Controls.Add(msoControlButton, 923, , , True)
' Start a new group.
cmbControl.BeginGroup = True
' Change the caption displayed for the control.
cmbControl.Caption = "Close Report"
End With
Set cmbControl = Nothing
Set cmbRightClick = Nothing
End Sub
Private Sub Report_Load()
CreateReportShortcutMenu
End Sub
Это путь над моей головой, но некоторые исследования, кажется, указывают, что вам нужно объявить '.CommandBar' на уровне класса. (https://msdn.microsoft.com/en-us/library/scff9c7c%28v=vs.90%29.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1) – MoondogsMaDawg
Нет, они являются точными как локальные переменные. – Andre