Forms and Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Soryt

    Forms and Form

    Hi everyone !

    1) An example from help:

    "Each Form object has a Controls collection, which contains all
    controls on the form. You can refer to a control on a form either
    by implicitly or explicitly referring to the Controls collection. Your
    code will be faster if you refer to the Controls collection implicitly.
    The following examples show two of the ways you might refer
    to a control named NewData on the form called OrderForm:

    ' Implicit reference.
    Forms!OrderForm !NewData

    ' Explicit reference.
    Forms!OrderForm .Controls!NewDa ta

    The next two examples show how you might refer to a control named NewData on
    a subform ctlSubForm contained in the form called OrderForm:

    Forms!OrderForm .ctlSubForm.For m!Controls.NewD ata
    Forms!OrderForm .ctlSubForm!New Data"

    Why is there a "." character after the name of the main form ? (and
    the same with a dot after "Controls" property). It's not a method
    or property ... And if you look at other key-word "Form, Report
    Properties" there is also an example:

    intOrderID = Forms!Orders!Or derDetails.Form !OrderID

    And now - there is a "!" - not "." wich is more logical for me.
    Why wasn't it this way in the last example ?

    And one more thing - I don't understand the meaning of property
    "form" - why to refer to itself ? Can't we refer just this way:

    Forms!Orders!Or dersDetails!Ord erID ???

    If we can do that in this way, why to use "form" property ?



    Thanks for all answers.

    PS. I use MS Access 2000 version 9.0.2812


  • MacDermott

    #2
    Re: Forms and Form

    In many cases, the dot and the bang are interchangable.
    In other cases, one or the other is required, and the wrong one won't work.
    Personally, I don't get too excited about the theoretical underpinnings; I
    just use what works.

    As for your question about the Form property, that one IS significant.
    Forms!Orders!Or derDetails refers to the subform control, which is located on
    the form Orders.
    This subform control contains a form, which is accessible using its Form
    property.
    The controls on the subform belong to this form, not to the subform control.
    Although I, too, have seen this form in help files:
    Forms!OrderForm .ctlSubForm!New Data
    I have never been successful in making it work without referring to the Form
    property of the subform control.

    Pozdrowienia
    - Turtle


    "Soryt" <dire@wp.pl> wrote in message
    news:brfk9g$q8v $1@atlantis.new s.tpi.pl...[color=blue]
    > Hi everyone !
    >
    > 1) An example from help:
    >
    > "Each Form object has a Controls collection, which contains all
    > controls on the form. You can refer to a control on a form either
    > by implicitly or explicitly referring to the Controls collection. Your
    > code will be faster if you refer to the Controls collection implicitly.
    > The following examples show two of the ways you might refer
    > to a control named NewData on the form called OrderForm:
    >
    > ' Implicit reference.
    > Forms!OrderForm !NewData
    >
    > ' Explicit reference.
    > Forms!OrderForm .Controls!NewDa ta
    >
    > The next two examples show how you might refer to a control named NewData[/color]
    on[color=blue]
    > a subform ctlSubForm contained in the form called OrderForm:
    >
    > Forms!OrderForm .ctlSubForm.For m!Controls.NewD ata
    > Forms!OrderForm .ctlSubForm!New Data"
    >
    > Why is there a "." character after the name of the main form ? (and
    > the same with a dot after "Controls" property). It's not a method
    > or property ... And if you look at other key-word "Form, Report
    > Properties" there is also an example:
    >
    > intOrderID = Forms!Orders!Or derDetails.Form !OrderID
    >
    > And now - there is a "!" - not "." wich is more logical for me.
    > Why wasn't it this way in the last example ?
    >
    > And one more thing - I don't understand the meaning of property
    > "form" - why to refer to itself ? Can't we refer just this way:
    >
    > Forms!Orders!Or dersDetails!Ord erID ???
    >
    > If we can do that in this way, why to use "form" property ?
    >
    >
    >
    > Thanks for all answers.
    >
    > PS. I use MS Access 2000 version 9.0.2812
    >
    >[/color]


    Comment

    • Soryt

      #3
      Re: Forms and Form

      [...][color=blue]
      > The controls on the subform belong to this form, not to the subform[/color]
      control.[color=blue]
      > Although I, too, have seen this form in help files:
      > Forms!OrderForm .ctlSubForm!New Data
      > I have never been successful in making it work without referring to the[/color]
      Form[color=blue]
      > property of the subform control.[/color]

      Does it mean that if I use an expression:

      Forms!OrderForm .ctlSubForm!New Data

      then I refer to NewData of the main form ?
      If it is so, then I get it :D

      Thanks for your quick reply.
      [color=blue]
      > Pozdrowienia
      > - Turtle[/color]

      Równie¿ pozdrawiam,
      Adrian :)


      Comment

      • MacDermott

        #4
        Re: Forms and Form

        I have never found the expression
        Forms!OrderForm .ctlSubForm!New Data
        to be useful for anything.
        Forms!OrderForm .ctlSubForm
        refers to the subform control;
        you can use it to access properties such as Top, Left, which are
        common to all controls, as well as specific properties like LinkMasterField s
        and LinkChildFields .
        In general, these are properties that relate the subform control to
        the main form it's sitting on.

        Another one of the properties of a subform control is its .Form property.
        This is a reference to the form which is contained in the form.
        Through this property, you can reference all of the properties of that
        form -
        including all its controls, its recordset, etc.

        To reference the control NewData on the main form, there's no need to make
        any reference to the subform control at all -
        that would just be
        Forms!OrderForm !NewData

        HTH
        - Turtle


        "Soryt" <dire@wp.pl> wrote in message
        news:brfmv5$9s3 $1@nemesis.news .tpi.pl...[color=blue]
        > [...][color=green]
        > > The controls on the subform belong to this form, not to the subform[/color]
        > control.[color=green]
        > > Although I, too, have seen this form in help files:
        > > Forms!OrderForm .ctlSubForm!New Data
        > > I have never been successful in making it work without referring to the[/color]
        > Form[color=green]
        > > property of the subform control.[/color]
        >
        > Does it mean that if I use an expression:
        >
        > Forms!OrderForm .ctlSubForm!New Data
        >
        > then I refer to NewData of the main form ?
        > If it is so, then I get it :D
        >
        > Thanks for your quick reply.
        >[color=green]
        > > Pozdrowienia
        > > - Turtle[/color]
        >
        > Równie¿ pozdrawiam,
        > Adrian :)
        >
        >[/color]


        Comment

        • Soryt

          #5
          Re: Forms and Form

          [...][color=blue]
          > To reference the control NewData on the main form, there's no need to make
          > any reference to the subform control at all -
          > that would just be
          > Forms!OrderForm !NewData[/color]

          Thank you for your comprehensive answer.



          Regards,

          Adrian.

          PS. I wonder why Forms!OrderForm .ctlSubForm!New Data
          works on my computer ... In my opinion Access should throw
          an exception, but it doesn't ... :\


          Comment

          Working...