Solved DisableRight-Click on a SUB-FORM (2 Viewers)

mloucel

Member
Local time
Today, 14:28
Joined
Aug 5, 2020
Messages
276
I am using:
Code:
Forms("FormName").ShortcutMenu = TempVars("SCM").value

FormName is the Name of the SUB-FORM, not of the MAIN FORM.

It works with the main Form, but not for the Sub-Form, the only way I've found to disable the Sub-Form sub menu is to go directly to the property tab

SCM.png


and disable it there, but just as a curiosity what will be the proper syntax for the Sub Form when is inside of the main form?

Help will be appreciated even if this is not possible.
 
just as a curiosity what will be the proper syntax for the Sub Form when is inside of the main form?
Something like:

Forms!Formname.SubformControlname.Form!Propertyname = Somevalue
 
Something like:

Forms!Formname.SubformControlname.Form!Propertyname = Somevalue
I got an error:
Error.png

this is what I have:
Forms!MenuF.frmAuthFullView.Form!ShortcutMenu = TempVars("SCM").value
 
I would remove some functionality to do some troubleshooting. Before attempting to set a value, try to read the value.

Debug.Print Forms!MenuF.frmAuthFullView.Form!ShortcutMenu
Debug.Print Forms!MenuF.frmAuthFullView.Form.Name
 
I'd never had a reason to do this before but both of these worked for me:

Code:
TempVars!SCM=False
Forms!frmPostcodeAddresses.fsubPostcodeAddresses1.Form.ShortcutMenu =TempVars!SCM

Code:
TempVars!SCM=True
Forms!frmPostcodeAddresses.fsubPostcodeAddresses1.Form.ShortcutMenu =TempVars("SCM").value

Did you remember to use the name of the subform control? If not, you will indeed get error 2465
 
Last edited:
I'd never had a reason to do this before but both of these worked for me:

Code:
TempVars!SCM=False
Forms!frmPostcodeAddresses.fsubPostcodeAddresses1.Form.ShortcutMenu =TempVars!SCM

Code:
TempVars!SCM=True
Forms!frmPostcodeAddresses.fsubPostcodeAddresses1.Form.ShortcutMenu =TempVars("SCM").value

Did you remember to use the name of the subform control? If not, you will indeed get error 2465
For some weird reason I keep getting the same Runtime Error 2465, Application-defined or object-defined error.

I know 100% your code is excellent and both forms work as they should be, but I am guessing something is going on while Loading the form.
Troubleshoot:
- When I try the Immediate I got the same error
- Clicking on " TempVars!SCM " tells me that the value is there in this particular case "True" [SCM is for the Admin other wise will be False]
- The error then is here: " Forms!MenuF.frmAuthFullView.Form.ShortcutMenu "
but I have use copy paste to be sure the names of the form are correct, I have no other way to troubleshoot.

Anyhow I finally decided the use the property and set it to NO for anyone including me or any other admin, sorting is not a life and dead situation in this form, but it was nice as admin.

So thanks Colin I really admire your knowledge and patience, and to everyone else that try to help me.

The reason I try this was because I found a user teaching the other users how to do the sort, it was nice, but when 2 or more users were doing it, generated an error and crashed the app, hence the Idea to allow the Admin only do the sort.

Anyhow, nobody will die so we are safe for now.

I have tested it in other forms and strangely enough the code works as you show me, no issues whatsoever. :oops:
 

Users who are viewing this thread

Back
Top Bottom