Form ShortcutMenu Help (1 Viewer)

riti90

Registered User.
Local time
Today, 20:52
Joined
Dec 20, 2017
Messages
44
Hi everyone,

I'm trying to add a button to a Form for disabling the ShortcutMenu of all forms.
Is it any chance I can Realize this?
I've gotten so far with the code for opening all the forms but I cannot finish it.
Thank You..
Public Function DisableShortMenu1()
'On Error GoTo Error_Handler
Dim frm As AccessObject, dB As Object
--Dim ShrtcutMnu As AccessObjectProperties -- maybe I'm doing wrong here...
--shrtcutmenu = frm.Properties(ShortcutMenu) -- or here...
Set dB = Application.CurrentProject.AllForms
For Each frm In dB
DoCmd.OpenForm frm.Name, acDesign, , , , acWindowNormal
ShrtcutMnu = False

'DoCmd.Close acForm, FrmName, acSaveNo
Next frm

Error_Handler_Exit:
On Error Resume Next
Set frm = Nothing
Set dB = Nothing
Exit Function

Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: CloseAllOpenFrms" & vbCrLf & _
"Error Description: " & Err.Description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
 
Last edited:

jleach

Registered User.
Local time
Today, 15:52
Joined
Jan 4, 2012
Messages
308
I don't think you need to access the properties collection, and I don't think you need any sort of shortcut menu object. As I recall, the property you're after is simply a text value that takes the name of the menu, so:

frm.ShortcutMenu = ""

... should suffice to remove the menu.
 

riti90

Registered User.
Local time
Today, 20:52
Joined
Dec 20, 2017
Messages
44
Thank You for the response. :)

I figured it out . it should have been..
Public Function DisableShortMenu1()
On Error GoTo Error_Handler
Dim frm As AccessObject, dB As Object

Set dB = Application.CurrentProject
For Each frm In dB.AllForms
DoCmd.OpenForm frm.Name, acDesign
'If Forms(frm.Name).AllowDesignChanges = True Then
Forms(frm.Name).ShortcutMenu = False
'End If

DoCmd.Close acForm, frm.Name, acSaveYes
Next frm

Error_Handler_Exit:
On Error Resume Next
Set frm = Nothing
Set dB = Nothing
Exit Function

Error_Handler:
MsgBox "The following error has occured." & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & _
"Error Source: CloseAllOpenFrms" & vbCrLf & _
"Error Description: " & Err.Description, _
vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Function
 

Users who are viewing this thread

Top Bottom