Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set AllowEdits Property of a subform of a subform

Posted on 2013-06-26
8
Medium Priority
?
589 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 58
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 58
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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

730 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