PC Review


Reply
Thread Tools Rate Thread

Referencing Subform Controls/Properties 2007

 
 
Dave
Guest
Posts: n/a
 
      13th Jan 2012
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.
 
Reply With Quote
 
 
 
 
Tony Toews
Guest
Posts: n/a
 
      16th Jan 2012
On Fri, 13 Jan 2012 08:08:57 -0800 (PST), Dave
<(E-Mail Removed)> wrote:

>Other than that or a change to the object model, I have no clue. Much
>appreciated if anyone has another idea.


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 see http://www.autofeupdater.com/
 
Reply With Quote
 
 
 
 
Dave
Guest
Posts: n/a
 
      17th Jan 2012
On Jan 15, 7:25*pm, Tony Toews <(E-Mail Removed)> wrote:
> On Fri, 13 Jan 2012 08:08:57 -0800 (PST), Dave
>
> <(E-Mail Removed)> wrote:
> >Other than that or a change to the object model, I have no clue. Much
> >appreciated if anyone has another idea.

>
> 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.
 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      21st Feb 2012
On Jan 16, 6:32*pm, Dave <(E-Mail Removed)> wrote:
> On Jan 15, 7:25*pm, Tony Toews <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On Fri, 13 Jan 2012 08:08:57 -0800 (PST), Dave

>
> > <(E-Mail Removed)> wrote:
> > >Other than that or a change to the object model, I have no clue. Much
> > >appreciated if anyone has another idea.

>
> > 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.- 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!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing Data in One Subform From Another Subform? HumanJHawkins Microsoft Access Form Coding 2 28th Feb 2009 02:16 AM
Referencing subform from another subform BobT Microsoft Access Form Coding 11 24th Sep 2008 05:28 PM
Referencing control in subform from subform's subform Kat Microsoft Access VBA Modules 5 19th Jun 2006 04:03 PM
Trying to disable subform (and have read webpage on subform property referencing) rgrantz Microsoft Access Form Coding 3 7th Dec 2004 04:31 AM
Urgent Help Needed: Referencing a control on a subform's subform =?Utf-8?B?VHJpc2hhQg==?= Microsoft Access Form Coding 7 3rd Nov 2004 05:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:37 PM.