[AccessD] Update the value of a control on parent form from subform

A.D.Tejpal adtp at touchtelindia.net
Sat Sep 10 09:42:34 CDT 2005


Arthur,

    Sample syntax for using With/End With blocks, while referring to controls on the parent form (from within subform), or on the subform (from within parent form) is given below.

    SF_01 is the name of control acting as container for the subform.

Best wishes,
A.D.Tejpal
--------------

Code In Subform's Module
===================================
With Me.Parent
    .Form("control1") = "Insertion-01 From Subform"
    .Form("control2") = "Insertion-02 From Subform"
End With
===================================

Code In Main form's Module
===================================
With Me
    .Form("control1") = 124
    .Form("control2") = "This is some text"
    With .SF_01
        .Form("control1") = True
        .Form("control2") = "This is some more text"
    End With
End With
===================================

  ----- Original Message ----- 
  From: Arthur Fuller 
  To: 'Access Developers discussion and problem solving' 
  Sent: Saturday, September 10, 2005 03:53
  Subject: [AccessD] Update the value of a control on parent form from subform


  Shamil recently assisted me with the syntax to refer to a control on a
  subform, and now I need to do the opposite from within a "With Me" block. I
  tried "Parent" as in the following sample line, with a couple of variations,
  but I got it wrong. 
  With Me
      .Parent.MyControl = 12345
      .Parent.Form.MyControl = 12345
      .Parent.Form.MyControl.Value = 12345
  End With

  And another thing about these "With Me" blocks. It appears from my
  experiments that you cannot nest them. I.e.
  With Me
      .control1 = 124
      .control2 = "This is some text"
      With .mySubForm
          .control1 = True
          .control2 = "This is some more text"
      End With
  End With

  Whereas one can next Case blocks, While loops, If blocks, etc. Can anyone
  think of a logical reason why With blocks do not conform to the general
  rule?
  TIA,
  Arthur




More information about the AccessD mailing list