Sub Sub Form Reference (from the main form) (1 Viewer)

KenRob

Registered User.
Local time
Today, 09:35
Joined
Mar 24, 2014
Messages
11
Hello All,

I am working on vb code for a MAccess form that would enable/disable editing on toggle. This button lives on the main form, so it needs to reference everything from there.

There is a main form, a sub form, and a sub-sub form. The code works perfectly for the main form and subform, but I am unable to get the reference right for the sub sub form. I have read about 10 blog posts about how to reference properly and tried each suggestion but I keep getting an error "You entered an expression that has an invalid reference to the property Form/Report."

Here are the references I have attempted as well as the results of the attempt:

Me.subform1.Form!subform2.Form.AllowDeletions = Me.tog_AllowEdits --> No

Me.subform1.Form.subform2fsub_Observation.Form.AllowDeletions = Me.tog_AllowEdits --> Worked once, and then stopped working???

Me!subform1.Form.subform2.Form.AllowDeletions = Me.tog_AllowEdits --> No

Me!subform1.Form!subform2.Form.AllowDeletions = Me.tog_AllowEdits --> No


---------

This is just a portion of the code of course. The subforms are named more meaningfully that shown above. I know that nested subforms are rare... but in this case they are necessary.

Thank you in advance!!!!!
:banghead::banghead::banghead:
Ken
 

spikepl

Eledittingent Beliped
Local time
Today, 17:35
Joined
Nov 3, 2010
Messages
6,144
Create a text box. Goto to the Control Source property. Click on the ellipses and pick expression builder. There navigate through forms and subforms to the control for which you want a reference and select it. Press Paste... now you have the reference - copy it. Delete text box. done.
 

KenRob

Registered User.
Local time
Today, 09:35
Joined
Mar 24, 2014
Messages
11
Hi Minty-- Thanks for your reply. I actually used that website for reference as well. I could go the route of referencing every single control, but I want to just be able to toggle allow edits etc on and off using the button. This works on the main form and the subform1 but not subform 2... Not sure why....
 

KenRob

Registered User.
Local time
Today, 09:35
Joined
Mar 24, 2014
Messages
11
Create a text box. Goto to the Control Source property. Click on the ellipses and pick expression builder. There navigate through forms and subforms to the control for which you want a reference and select it. Press Paste... now you have the reference - copy it. Delete text box. done.

Thanks for your reply...

But this doesn't work in this instance. I need to reference a nested subform from the main (parent) form. When I attempted your suggestion, I just ended up with the basic reference... Forms![fsub_Subform2]... instead of the full "relative" reference.

Any other ideas guys? Seems like it should be fairly straightforward, but I am :banghead:
 

spikepl

Eledittingent Beliped
Local time
Today, 17:35
Joined
Nov 3, 2010
Messages
6,144
Your understanding doesn't work in this instance! :D


You take the reference and replace the part referring to the form you are on with me!
 

KenRob

Registered User.
Local time
Today, 09:35
Joined
Mar 24, 2014
Messages
11
Your understanding doesn't work in this instance! :D

If you see my original post, you will notice that I have utilized me! and "understand" it.

Using the control source builder did not give me a RELATIVE reference to the nested subform--- it "skipped" over the subform that contains the nested subform and therefore does not work.
 

Minty

AWF VIP
Local time
Today, 16:35
Joined
Jul 26, 2013
Messages
10,354
I think I know what the problem with this might be.

If you set edits off in the first sub form you cannot set edits back on on the sub.sub form as it inherits the behaviour of the parent. It cannot be edited or have it's properties changed as it's a control on a form that is locked.

Maybe... (I'm sure I stumbled on this problem before and took ages to work it out.)
 

KenRob

Registered User.
Local time
Today, 09:35
Joined
Mar 24, 2014
Messages
11
I think I know what the problem with this might be.

If you set edits off in the first sub form you cannot set edits back on on the sub.sub form as it inherits the behaviour of the parent. It cannot be edited or have it's properties changed as it's a control on a form that is locked.

Maybe... (I'm sure I stumbled on this problem before and took ages to work it out.)

Great thought Minty! I would not have thought of that...

It seems like the nested subform does not inherit it's parent's behavior though because it doesn't lock when its parent is locked.

I am not sure if that is proof either way though.

Thanks for giving it some thought. I will post something if I resolve the issue.
Have a good one!
 

Users who are viewing this thread

Top Bottom