Solved

Set AllowEdits Property of a subform of a subform

Posted on 2013-06-26
8
541 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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
 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

809 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