Solved DisableRight-Click on a SUB-FORM

mloucel

Member
Local time
Today, 02:30
Joined
Aug 5, 2020
Messages
309
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:
 
As I mentioned, I suspect your subform that triggered the error had a control name that was different to the name of the subform itself.
You must always reference the name of the subform control
 
like what others are telling it is:

Forms!MenuF!SubFormContainerName.Form.ShortcutMenu = TempVars("SCM").value

to know the SubformContainerName, in design view click on the subform and make sure
that a Yellow rectangle surrounds the subform.
now, check the Name on it's Property and substitute the name to the expression above.
subform.jpg
 
like what others are telling it is:

Forms!MenuF!SubFormContainerName.Form.ShortcutMenu = TempVars("SCM").value

to know the SubformContainerName, in design view click on the subform and make sure
that a Yellow rectangle surrounds the subform.
now, check the Name on it's Property and substitute the name to the expression above.
View attachment 116224
Thanks, I got, it, and I got the name right, but I just found out another thing, I am not sure if that makes a difference, the form is based on a query that has 2 nested queries, All the other forms do not work out of a query except this one.
Could that make any difference ?
Thanks.
Maurice.
 

Users who are viewing this thread

Back
Top Bottom