Trying to allow edit on a subform from a command button on the main form

SteveL13
SteveL13 used Ask the Experts™
on
I'm trying to allow edit on a sub-form from a command button on the main for with the following code.  But it isn't working.

Forms!subfrmWorkOrderDetail.Form.AllowEdits = True

Can someone tell me what is wrong with the code?  When I click the command button I get an error...  Runtime error 2450.  Can't find the referenced form.

--Steve
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017
Commented:
You can use:
Me.subfrmWorkOrderDetail.Form.AllowEdits = True
OR
Forms!yourmainformname.Form!subfrmWorkOrderDetail.Form.AllowEdits = True

Use the "Me." syntax when referencing an object on the form where the code is running.  In this case, the subform is a control on the main form where the code is running.  Use the more formal reference when you are outside the scope of the object you are referencing.  Just keep in mind that the object you are referencing Must be open.  So, for example, if you were using a popup form instead of an embedded subform, you would need to open the popup and then use the "Forms!yourpopupformname.Form.AllowEdits" reference.

Author

Commented:
Extremely informative.  Thank you very much!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial