Solved

Set AllowEdits Property of a subform of a subform

Posted on 2013-06-26
8
548 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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…

820 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