Reference form objects from a module

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

    #1

    Reference form objects from a module

    Hi

    I have a module where I put all my functions and sub procedures. How do I
    from the module best reference objects in other forms?

    I have a form with a datagrid, and in the module I have a procedure to fill
    this datagrid.
    The datagrid is called dg, the form frmEventMain

    Would this be correct:

    frmEventMain.dg .Datasource = dt when I reference the datagrid in another
    form?

    /A.

  • Lee

    #2
    Re: Reference form objects from a module

    Andy:

    It's not clear to me if frmEventMain is an instance of a form or the
    name of the class wherein the form is defined. Assuming it's an
    instance of the form you could...

    1) Call your proc passing frmEventMain as a parameter
    2) Call your proc passing frmEventMain.dg as a parameter
    3) Assuming frmEventMain is visible within your proc, you could access
    frmEventMain.dg directly.

    My preference would be #2 because it would make your proc more
    generally useful.

    --
    // Lee Silver
    // Information Concepts Inc.

    Andy.I wrote:
    Hi
    >
    I have a module where I put all my functions and sub procedures. How do I
    from the module best reference objects in other forms?
    >
    I have a form with a datagrid, and in the module I have a procedure to fill
    this datagrid.
    The datagrid is called dg, the form frmEventMain
    >
    Would this be correct:
    >
    frmEventMain.dg .Datasource = dt when I reference the datagrid in another
    form?
    >
    /A.

    Comment

    • Andy.I

      #3
      Re: Reference form objects from a module

      Thanks

      I'll give it a try
      "Lee" <lsilver@inform ation-concepts.comwro te in message
      news:1169033939 .300863.207150@ v45g2000cwv.goo glegroups.com.. .
      Andy:
      >
      It's not clear to me if frmEventMain is an instance of a form or the
      name of the class wherein the form is defined. Assuming it's an
      instance of the form you could...
      >
      1) Call your proc passing frmEventMain as a parameter
      2) Call your proc passing frmEventMain.dg as a parameter
      3) Assuming frmEventMain is visible within your proc, you could access
      frmEventMain.dg directly.
      >
      My preference would be #2 because it would make your proc more
      generally useful.
      >
      --
      // Lee Silver
      // Information Concepts Inc.
      >
      Andy.I wrote:
      >Hi
      >>
      >I have a module where I put all my functions and sub procedures. How do I
      >from the module best reference objects in other forms?
      >>
      >I have a form with a datagrid, and in the module I have a procedure to
      >fill
      >this datagrid.
      >The datagrid is called dg, the form frmEventMain
      >>
      >Would this be correct:
      >>
      >frmEventMain.d g.Datasource = dt when I reference the datagrid in another
      >form?
      >>
      >/A.
      >

      Comment

      • Phill W.

        #4
        Re: Reference form objects from a module

        Andy.I wrote:
        I have a module where I put all my functions and sub procedures. How do
        I from the module best reference objects in other forms?
        If a method requires a reference to a Form then pass it one as an
        argument to the method.
        Better still, if the method primarily affects the Form based on other
        data that you supply, move the method into the Form class.
        I have a form with a datagrid, and in the module I have a procedure to
        fill this datagrid.
        I would suggest that's the wrong way round.
        I would attach this method to the Form and pass the data, however you
        retrieve it, to the method.

        HTH,
        Phill W.

        Comment

        Working...