How to edit shortcut menu bar for a form

J

Julia B

Hi

I want a shortcut menu bar for one of my forms. I've gone to Tools|
Customize | Toolbars and created a new one called SDIShortcut. I then changed
its properties to make it a popup, which confirmed that it had been made a
shortcut menu.

All fine so far.......

However, now I cannot seem to be able to add commands to it. I've made
Shortcut Menus visible and I can see it, but if I try and drag and drop
commands from the Customize Toolbars box onto it, it just doesn't happen. If
I right click on the SDIShortcut menu, nothing happens.

Any clues?

Thanks!
Julia
 
J

Julia B

Hi all,

Please ignore my post. I found out that there was a technique to dropping
the command in the right place. I just had the mouse in the wrong place.

Doh!!

Julia
 
D

Dale Fye

Julia,

I've found that I prefer to build my shortcut menus using code. Although
you can import menus using the GetExternalData menu, I find this to be much
more flexible. Additionally, using this method, you can create textbox or
combo box controls in your menus as well. I like to use this functionality
for my Options menu.
By using code, I can easily copy and past my "mod_Menus" module from one
application to another and use it, or modify it. The attached is for my
FormMenu, which just has "Close" and "Quit" functions, but I have separate
routines that define my textbox shortcut menus, report shortcut menus, and
the like.

Public Sub FormMenu()

Dim cbr As Object
Dim cbrButton As Object

DeleteCmdBar ("MyFormMenu")
On Error GoTo FormMenuError

DoCmd.Hourglass True

Set cbr = CommandBars.Add("MyFormMenu", BarPopup, , True)

With cbr

Set cbrButton = cbr.Controls.Add(ControlButton, , , , True)
With cbrButton
.Caption = "&Close"
.Tag = "Close"
.OnAction = "=fnCloseForm()"
End With

Set cbrButton = cbr.Controls.Add(ControlButton, , , , True)
With cbrButton
.Caption = "&Quit"
.Tag = "Quit"
.OnAction = "=fnQuit()"
End With

End With

DoCmd.Hourglass False
Exit Sub
FormMenuError:
MsgBox "ReportMenu error" & vbCrLf
End Sub

Public Sub DeleteCmdBar(BarName As String)

Dim intLoop As Integer

'If an error is generated, it is because the command bar doesn't exist,
ignore it
On Error GoTo DeleteCmdBar_Error
CommandBars(BarName).Delete
Exit Sub

DeleteCmdBar_Error:
Err.Clear

End Sub



--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
U

UpRider

Dale, I get compile error, Variable not Defined, for BarPopup

Set cbr = CommandBars.Add("MyFormMenu", BarPopup, , True)

UpRider
 
D

Dale Fye

Sorry, there are some constants that need to be declared as well.

Const BarPopup = 5
Const ControlButton = 1
Const ControlEdit = 2
Const ControlComboBox = 4
Const ButtonUp = 0
Const ButtonDown = -1

Dale
 
U

UpRider

Thanks, Dale

Uprider

Dale Fye said:
Sorry, there are some constants that need to be declared as well.

Const BarPopup = 5
Const ControlButton = 1
Const ControlEdit = 2
Const ControlComboBox = 4
Const ButtonUp = 0
Const ButtonDown = -1

Dale
 

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