Referencing Subform Controls/Properties 2007

D

Dave

Has something changed in Access 2007 when referencing subform controls
or properties? Until we migrated from 2000/2003 to 2007, my syntax
worked. I have spent the better part of two days trying to solve error
2455: "You entered an expression that has an invalid reference to the
property Form/Report".
I have: form name - "frmNP"; subForm control name - "subNPfrm";
form name on subform control - "frmNPsub"
When referencing subform properties, I used the syntax

With Forms("frmNP").Controls("subNPfrm").Form
.DataEntry = True
.etc, etc.
End With

When referencing controls on a subform, I used Forms!frmNP!
subNPfrm.Form!txtNPno
that is, Forms![FormName]![subformControlName].Form!
ControlNameOnSubform
It should be obvious that I distinguish between the object names and
their data sources by virtue of the fact that this used to work, but I
say so here just to clarify that I'm aware of the potential mix up.
Other than that or a change to the object model, I have no clue. Much
appreciated if anyone has another idea.
Thanks.
 
T

Tony Toews

D

Dave

If the code you are executing is in the subform you could try the
Parent syntax.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages -http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog -http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated seehttp://www.autofeupdater.com/

I'm trying to run this on the main form open event
With Forms("frmNP").Controls("subNPfrm").Form
.AllowAdditions = False
.DataEntry = False
.AllowDeletions = False
End With
and am using the syntax I mentioned that I usually use for the sub
form properties. I guess I will have to find another way. Perhaps if I
move that into the subform open event, but then I will have to deal
with passing or referencing the main form open mode (copy, edit, new)
in order to set the subform properties.It's just perplexing that it
used to work.
 
D

Dave

I'm trying to run this on the main form open event
            With Forms("frmNP").Controls("subNPfrm").Form
                .AllowAdditions = False
                .DataEntry = False
                .AllowDeletions = False
            End With
and am using the syntax I mentioned that I usually use for the sub
form properties. I guess I will have to find another way. Perhaps if I
move that into the subform open event, but then I will have to deal
with passing or referencing the main form open mode (copy, edit, new)
in order to set the subform properties.It's just perplexing that it
used to work.- Hide quoted text -

- Show quoted text -

An update for anyone who might stumble upon this thread. Issue has
been solved but is weird.
This form is being used in 1 of 3 modes (add, view saved, edit in
progress). Setting the DataEntry property of the main form in the Open
event according to the mode (not previously mentioned) causes the main
form load event to fire. In there, I was setting subForm recordsource
property then returning to the main form Open event. The problem code
then ran fine for the view mode, but not for edit. For edit mode, I
had changed the approach and remarked out the recordsource setting of
the subform. When execution returned to the main form open event, I
still needed to set control properties on the subform but could not
get the same syntax to work. It's as if setting the subform
recordsource caused it to be instantiated, which allowed me to drill
down to it in the main form open event. When I stopped setting the
recordsource for a mode, it failed.
Don't really know why, but that's my story and I'm sticking to it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top