shortcut menus in access2007 (expert help needed ASAP)

M

Mark Andrews

I need to create a shortcut menu in access2007 so users can right click on
reports in preview mode to print them and do other common reporting actions.
Needed when report is run in a dialog window and ribbon is not available.

I need the shortcut menu to work in the access 2007 runtime.

Question:
what's the best way to go about this?

I would like the menu to be similar to the default menu in access2007:
- print...
- zoom (with dropdown)
- one page
- multiple pages
- page setup...
- a few custom items (export to pdf), email pdf
- close

If possible I would like the images as well.

I have built shortcut menus in code, however not an expert of how to get the
pictures and the default actions (custom menus with pictures I can do).

I need this ASAP,
Thanks for any help in advance,
Mark
 
L

Lynn Trapp

Mark,
Search help for "Shortcut menu" and it will return a hit named "Create
custom menus and shortcut menus by using macros". The instructions are there.
 
M

Mark Andrews

Let me be more specific:
I figured out how to find various faceID values by looping through the
commandbar collection
Example: faceid 2521 is print and 25 is zoom

If I create the shortcut menu in code:
1. Is there a way to have the action be a default action or does everything
have to use .ONAction method and then use a function to code the appropriate
action?

For things like zoom (where it would be nice to have the dropdown choices
like the default shortcut menu) it ends up being more code.

Has anyone done a custom shortcut menu for reporting in VBA code they could
share?

I'm not even sure how to build one in Access2003 with the zoom feature
(using the regular customize menus etc...). Maybe I could import it from a
2003 db if I create it that way.

How about code to bring up the print setup box? I don't usually do this.

Any comments on anything here would help me out.

Thanks,
Mark
 
M

Mark Andrews

For my report right click shortcut menu.
Final code ended up like this for anyone that this might help.
I just call CreateReportPopupMenu at the start of the program and reference
the shortcut menu "RPTReportPopup" in each report.
Works find in the Access runtime (needed especially when opening reports in
a dialog window)!

Public Function CreateReportPopupMenu()
On Error GoTo Err_CreateReportPopupMenu
'Creates the popup menus that are used for reports (right click to do
certain actions)

Dim MenuName As String
Dim CB As CommandBar
Dim CBB As CommandBarButton

MenuName = "RPTReportPopup"

'delete menu if it already exists
If fIsCreated(MenuName) Then
Application.CommandBars(MenuName).Delete
End If

'create menu and appropriate commandbuttons
Set CB = Application.CommandBars.Add(MenuName, msoBarPopup, False,
False)

'add command button for "Print..."
Set CBB = CB.Controls.Add(msoControlButton, 15948, , , True)

'add command button for "Quick Print"
Set CBB = CB.Controls.Add(msoControlButton, 2521, , , True)
CBB.Caption = "Quick Print"

'add command button for "Page Setup..."
Set CBB = CB.Controls.Add(msoControlButton, 247, , , True)
CBB.BeginGroup = True

'add command button for "Export to PDF"
Set CBB = CB.Controls.Add(msoControlButton, 12499, , , True)
CBB.BeginGroup = True
CBB.Caption = "Export to PDF..."

'add command button for "Email Report (PDF)"
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Email Report (PDF)..."
CBB.Tag = "Email Report (PDF)..."
CBB.FaceId = 2188
CBB.OnAction = "=ReportAction(1)"

'add command button for "Close"
Set CBB = CB.Controls.Add(msoControlButton, 923, , , True)
CBB.BeginGroup = True
CBB.Caption = "Close Report"

Exit_CreateReportPopupMenu:
Set CB = Nothing
Set CBB = Nothing
Exit Function

Err_CreateReportPopupMenu:
MsgBox Err.Description
Resume Exit_CreateReportPopupMenu

End Function

Function fIsCreated(strMenuName) As Boolean

Dim intNumberMenus As Integer
Dim i As Integer

intNumberMenus = Application.CommandBars.Count

fIsCreated = False

For i = 1 To intNumberMenus
If Application.CommandBars(i).Name = strMenuName Then
fIsCreated = True
i = intNumberMenus
End If
Next

End Function


Public Function ReportAction(ActionID As Long)
On Error GoTo Err_ReportAction
'used by popup menu "RPTReportPopup" for custom buttons
'ActionID = 1 (email the report as a pdf attachment)

Select Case ActionID
Case 1: DoCmd.SendObject acSendReport, Screen.ActiveReport.Name,
acFormatPDF
End Select

Exit_ReportAction:
Exit Function

Err_ReportAction:
MsgBox Err.Description
Resume Exit_ReportAction

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top