locked
Referencing a control in a subform from a subform RRS feed

  • Question

  • I have form A1 which has a subform B1-B5 which I can change using .sourceobject when opening form A1, However B1 now has a subform C1 which has the update button how do I reference a control on form B1 from form C1?

    I tried 'forms[A1]![B1]![controlname] ','forms[A1].form![B1]![controlname] ','forms[A1]![B1].form![B1]![[controlname]'

    Thanks

    Martin

     

    Monday, November 14, 2011 4:31 PM

Answers

  • it is me.parent[controlname]!
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 4:38 PM
  • Try

    =[Parent]![ControlName]

    or

    =[Forms]![A1]![B1]![ControlName]

    where B1 is the name of the subform as a control on the main form A1 (not the name of the source object).


    Regards, Hans Vogelaar
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 4:39 PM
  • Me.Parent!ControlName

    Or

    Forms!A1!SubFormControlB1Name.Form!ControlName


    Uno+
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 9:12 PM
  • To have a good idea on how to refer to Controls of a subform of a Subform or the other way around, see this nice thread:

    http://access.mvps.org/access/forms/frm0031.htm

     

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 10:12 PM
  •     In this context, my sample db named FormsSubformsReference might also be of interest. It is in access 2000 file format and is available at Rogers Access Library. Link:
     
        The db covers all likely combinations of origin & destination controls located on the parent as well as subforms representing different levels of nesting. Nesting upto three levels deep is represented.
     
        It presents a visual ready reckoner as well. On selection of origin & destination controls, corresponding VBA code gets displayed simultaneously  - at the bottom. 
     
        Apart from showing the required syntax for (a) referring to controls of one group of nested subforms from another group of nested subforms and (b) referring to subroutines (contained in form's modules) across various levels of nested subforms, the sample db demonstrates the syntax for referring controls on forms / nested subforms in SQL statements.

        Dbl clicking any text box on main parent form or various nested subforms at left, causes its value to be picked up by the query, results of which, are displayed in the innermost nested subform at right. Simultaneously, the SQL used in source query, gets displayed at bottom.
     
    Best wishes,
    A.D. Tejpal
    ------------

    A.D. Tejpal
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Tuesday, November 15, 2011 3:57 AM

All replies

  • it is me.parent[controlname]!
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 4:38 PM
  • Try

    =[Parent]![ControlName]

    or

    =[Forms]![A1]![B1]![ControlName]

    where B1 is the name of the subform as a control on the main form A1 (not the name of the source object).


    Regards, Hans Vogelaar
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 4:39 PM
  • Me.Parent!ControlName

    Or

    Forms!A1!SubFormControlB1Name.Form!ControlName


    Uno+
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 9:12 PM
  • To have a good idea on how to refer to Controls of a subform of a Subform or the other way around, see this nice thread:

    http://access.mvps.org/access/forms/frm0031.htm

     

    Hope this helps,


    Daniel van den Berg | Washington, USA | "Anticipate the difficult by managing the easy"
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Monday, November 14, 2011 10:12 PM
  •     In this context, my sample db named FormsSubformsReference might also be of interest. It is in access 2000 file format and is available at Rogers Access Library. Link:
     
        The db covers all likely combinations of origin & destination controls located on the parent as well as subforms representing different levels of nesting. Nesting upto three levels deep is represented.
     
        It presents a visual ready reckoner as well. On selection of origin & destination controls, corresponding VBA code gets displayed simultaneously  - at the bottom. 
     
        Apart from showing the required syntax for (a) referring to controls of one group of nested subforms from another group of nested subforms and (b) referring to subroutines (contained in form's modules) across various levels of nested subforms, the sample db demonstrates the syntax for referring controls on forms / nested subforms in SQL statements.

        Dbl clicking any text box on main parent form or various nested subforms at left, causes its value to be picked up by the query, results of which, are displayed in the innermost nested subform at right. Simultaneously, the SQL used in source query, gets displayed at bottom.
     
    Best wishes,
    A.D. Tejpal
    ------------

    A.D. Tejpal
    • Marked as answer by Bruce Song Friday, November 25, 2011 12:48 PM
    Tuesday, November 15, 2011 3:57 AM