Solved

Set AllowEdits Property of a subform of a subform

Posted on 2013-06-26
8
572 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

630 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