Solved

Set AllowEdits Property of a subform of a subform

Posted on 2013-06-26
8
529 Views
Last Modified: 2013-07-13
I'm using VBA code in Access 2002 to set the AllowEdits property of a subform of a subform. The subform and sub-subform names are provided by query values in the code. For example:

My query column Parent1 is the main form subform and the query column FormName is the name of the subform subform.

In the example Parent1="frmsubHurnEdit" and FormName="frmsub1EditHURN_Financials"

The following suntax raises the error 2455 invalid reference to the property form/report:

Forms("frmScorecard").Controls(rs!Parent1).Controls(rs!FormName).Form.AllowEdits = blnReadWrite
0
Comment
Question by:paulmcneil
  • 4
  • 4
8 Comments
 
LVL 57
ID: 39277838
Paul,

  Subform *control* names and subform names are not the same thing and may be different.

 Open your parent form, right click on the subform control, select properties, and check what the name is.

 Ditto for the rest of the children.

Jim.
0
 

Author Comment

by:paulmcneil
ID: 39278070
JDettman,
In my case my subform names and SourceObject names are the same, so the example I gave are the valid subform and sub-subform names in the main form "frmScorecard". So it's frmScorecard
frmsubHurnEdit subform of frmScorecard
frmsub1EditHURN_Financials subform of frmsubHurnEdit
Thanks
0
 
LVL 57
ID: 39278171
Well you look to be off then with this:

Forms("frmScorecard").Controls(rs!Parent1).Controls(rs!FormName).Form.AllowEdits = blnReadWrite

as you just described frmScorecard as the parent of frmsubHurnEdit

Your syntax should be:

Forms("frmScorecard")(rs!FormName).Form.AllowEdits = blnReadWrite

assuming rs!FormName is the name of the subform.

Jim.
0
 

Author Comment

by:paulmcneil
ID: 39278486
JDettman
Your example is fien for form + subform, but not for form + subform + susubform.

I need something like this to work (this raises an error)

Forms("frmScorecard")(rs!Parent1).Form.controls(rs!FormName).Form.AllowEdits = blnReadWrite
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 57
ID: 39278703
<<I need something like this to work (this raises an error)>>

 Don't see why that should not work, but try:

Forms("frmScorecard")(rs!Parent1)(rs!FormName).AllowEdits = blnReadWrite

The Form property is the default for a subform control and the controls collection is the default collection for a form, so you don't have to use either of those.

 So in the above, rs!Parent1 should be the name of the subfrom control on the main form, and rs!FormName should be the name of the subform control on the 1st subform.

If that does not work, then you need to check that your subform control names and subform names are really one in the same.

And if they are, then please post the form in a sample db.

Jim.
0
 

Accepted Solution

by:
paulmcneil earned 0 total points
ID: 39282396
Thanks for yur help Jim. I realized that my call to the procedure which needs to reference form/subform/subform was being made prematurely in an OnOpen event. I changed the call to an even after the main form and subforms are opened and now this syntax works fien as you expected it should:

Forms(rs!FormName).Controls(rs!SubFormName).Form!cmdAddDiscrepancy.Enabled = blnReadWrite
0
 
LVL 57
ID: 39282411
Good to hear!  Make sure you accept your last comment as answer.

Jim.
0
 

Author Closing Comment

by:paulmcneil
ID: 39323034
Figured it out myself
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now