Referencing Subform Controls/Properties 2007

Discussion in 'Microsoft Access' started by Dave, Jan 13, 2012.

  1. Dave

    Dave Guest

    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.
     
    Dave, Jan 13, 2012
    #1
    1. Advertisements

  2. Dave

    Tony Toews Guest

    On Fri, 13 Jan 2012 08:08:57 -0800 (PST), Dave
    <> 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/
     
    Tony Toews, Jan 16, 2012
    #2
    1. Advertisements

  3. Dave

    Dave Guest

    On Jan 15, 7:25 pm, Tony Toews <> wrote:
    > On Fri, 13 Jan 2012 08:08:57 -0800 (PST), Dave
    >
    > <> 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.
     
    Dave, Jan 16, 2012
    #3
  4. Dave

    Dave Guest

    On Jan 16, 6:32 pm, Dave <> wrote:
    > On Jan 15, 7:25 pm, Tony Toews <> wrote:
    >
    >
    >
    >
    >
    > > On Fri, 13 Jan 2012 08:08:57 -0800 (PST), Dave

    >
    > > <> 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!
     
    Dave, Feb 21, 2012
    #4
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. April Marano
    Replies:
    3
    Views:
    169
    Gary Walter
    Jul 11, 2004
  2. Tru
    Replies:
    1
    Views:
    208
    Van T. Dinh
    Aug 31, 2004
  3. Fay Yocum

    Referencing controls

    Fay Yocum, Jul 24, 2005, in forum: Microsoft Access
    Replies:
    6
    Views:
    208
    Fay Yocum
    Jul 24, 2005
  4. Replies:
    0
    Views:
    628
  5. alekm

    referencing controls

    alekm, Nov 2, 2009, in forum: Microsoft Access
    Replies:
    1
    Views:
    154
    RonaldoOneNil
    Nov 2, 2009
Loading...

Share This Page