Beginners problem with multiple forms

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

    #1

    Beginners problem with multiple forms

    Hi

    Can't get my head round something which I reckon should be simple.

    My app has a main form (frmMain). MdiContainer set to true.
    A menu item triggers a new form (frmSelect) whose parent is frmMain
    Button on frmSelect triggers a new form (frmReport) whose parent also needs
    to be frmMain

    When frmReport loads and displays I don't want user to see frmSelect, but I
    don't want to close it.

    When frmReport closes I want to re-display frmSelect so user can make new
    selection for report or close Select form

    My code so far is

    On frmMain .......

    Private Sub mnuItem1_Click( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles mnuItem1.Click
    Dim f1 As New frmSelec
    f1.MdiParent = Me
    f1.Show()
    End Sub

    On frmSelect .......

    Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button4.Click
    Dim f2 As New frmReport
    Me.Visible = False
    f2.MdiParent = ActiveForm
    f2.Show()
    End Sub

    What do I need to put on the "closed" event of frmReport to get frmSelect to
    become visible again. And have I used the best method of setting the parent
    form for frmReport. I had to make frmSelect invisible to get the frmMain as
    the active form to set it as the parent form. Otherwise a line "f2.mdipare nt
    = me" was trying to set frmSelect as the parent for frmReport

    Thanks in anticipation

    Regards

    Michael Bond
  • Armin Zingler

    #2
    Re: Beginners problem with multiple forms

    "mabond" <mabond@discuss ions.microsoft. com> schrieb[color=blue]
    > Hi
    >
    > Can't get my head round something which I reckon should be simple.
    >
    > My app has a main form (frmMain). MdiContainer set to true.
    > A menu item triggers a new form (frmSelect) whose parent is frmMain
    > Button on frmSelect triggers a new form (frmReport) whose parent
    > also needs to be frmMain
    >
    > When frmReport loads and displays I don't want user to see
    > frmSelect, but I don't want to close it.
    >
    > When frmReport closes I want to re-display frmSelect so user can
    > make new selection for report or close Select form
    >
    > My code so far is
    >
    > On frmMain .......
    >
    > Private Sub mnuItem1_Click( ByVal sender As System.Object, ByVal e
    > As System.EventArg s) Handles mnuItem1.Click
    > Dim f1 As New frmSelec
    > f1.MdiParent = Me
    > f1.Show()
    > End Sub
    >
    > On frmSelect .......
    >
    > Private Sub Button4_Click(B yVal sender As System.Object, ByVal e
    > As System.EventArg s) Handles Button4.Click
    > Dim f2 As New frmReport
    > Me.Visible = False
    > f2.MdiParent = ActiveForm
    > f2.Show()
    > End Sub
    >
    > What do I need to put on the "closed" event of frmReport to get
    > frmSelect to become visible again. And have I used the best method
    > of setting the parent form for frmReport. I had to make frmSelect
    > invisible to get the frmMain as the active form to set it as the
    > parent form. Otherwise a line "f2.mdipare nt = me" was trying to set
    > frmSelect as the parent for frmReport[/color]


    Use f2.mdiparent = me.Mdiparent instead.

    In frmMain, hold the references to frmSelect and frmReport in two fields.
    Don't use the local variable f1 in mnuItem1_Click but the field in frmMain.
    Same with frmReport: In Button4_click, raise an event notifying the
    MDIparent that either frmReport has been opened, or that the MDIparent is to
    open frmReport on it's own. If you do the former, pass the reference to the
    new form along. In both cases, store the reference to frmReport in a field
    in frmMain. Now that you have the reference, you can handle frmReport's
    closing event. There you can reopen or reshow frmSelect. In addition,
    handled both Form's closed event to set the references to Nothing.


    Armin

    Comment

    • Cerebrus99

      #3
      Re: Beginners problem with multiple forms

      Handle the "Closing" event of the forms, not the "Closed" event.

      "mabond" <mabond@discuss ions.microsoft. com> wrote in message
      news:7803CE2B-7D15-48E7-9A2B-69946F71BC73@mi crosoft.com...[color=blue]
      > Hi
      >
      > Can't get my head round something which I reckon should be simple.
      >
      > My app has a main form (frmMain). MdiContainer set to true.
      > A menu item triggers a new form (frmSelect) whose parent is frmMain
      > Button on frmSelect triggers a new form (frmReport) whose parent also[/color]
      needs[color=blue]
      > to be frmMain
      >
      > When frmReport loads and displays I don't want user to see frmSelect, but[/color]
      I[color=blue]
      > don't want to close it.
      >
      > When frmReport closes I want to re-display frmSelect so user can make new
      > selection for report or close Select form
      >
      > My code so far is
      >
      > On frmMain .......
      >
      > Private Sub mnuItem1_Click( ByVal sender As System.Object, ByVal e As
      > System.EventArg s) Handles mnuItem1.Click
      > Dim f1 As New frmSelec
      > f1.MdiParent = Me
      > f1.Show()
      > End Sub
      >
      > On frmSelect .......
      >
      > Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
      > System.EventArg s) Handles Button4.Click
      > Dim f2 As New frmReport
      > Me.Visible = False
      > f2.MdiParent = ActiveForm
      > f2.Show()
      > End Sub
      >
      > What do I need to put on the "closed" event of frmReport to get frmSelect[/color]
      to[color=blue]
      > become visible again. And have I used the best method of setting the[/color]
      parent[color=blue]
      > form for frmReport. I had to make frmSelect invisible to get the frmMain[/color]
      as[color=blue]
      > the active form to set it as the parent form. Otherwise a line[/color]
      "f2.mdipare nt[color=blue]
      > = me" was trying to set frmSelect as the parent for frmReport
      >
      > Thanks in anticipation
      >
      > Regards
      >
      > Michael Bond[/color]


      Comment

      • mabond

        #4
        Re: Beginners problem with multiple forms

        Armin

        Thanks for this. The solution to setting the mdiparent worked.

        I expect the main suggestion also works but I haven't a clue how to put
        together what you propose ...... and I should know but somehow I've got a
        mental block with forms in vb.net.

        If I understand I should have two (invisible?) text boxes on frmMain? But
        how do I get them to reference frmSelect and frmReport as you suggest. And do
        I use these references to create a "new" instance of my form as I would with
        "dim f1 as new frmSelect"

        Sorry I know I'm being "thick" but since I tried to move from vb6 to vb.net
        I just cannot grasp how to work with my forms..... even when helpful users
        such as yourself point me in the right direction

        Thanks for your help (and patience) so far

        Regards

        Michael Bond



        "Armin Zingler" wrote:
        [color=blue]
        > "mabond" <mabond@discuss ions.microsoft. com> schrieb[color=green]
        > > Hi
        > >
        > > Can't get my head round something which I reckon should be simple.
        > >
        > > My app has a main form (frmMain). MdiContainer set to true.
        > > A menu item triggers a new form (frmSelect) whose parent is frmMain
        > > Button on frmSelect triggers a new form (frmReport) whose parent
        > > also needs to be frmMain
        > >
        > > When frmReport loads and displays I don't want user to see
        > > frmSelect, but I don't want to close it.
        > >
        > > When frmReport closes I want to re-display frmSelect so user can
        > > make new selection for report or close Select form
        > >
        > > My code so far is
        > >
        > > On frmMain .......
        > >
        > > Private Sub mnuItem1_Click( ByVal sender As System.Object, ByVal e
        > > As System.EventArg s) Handles mnuItem1.Click
        > > Dim f1 As New frmSelec
        > > f1.MdiParent = Me
        > > f1.Show()
        > > End Sub
        > >
        > > On frmSelect .......
        > >
        > > Private Sub Button4_Click(B yVal sender As System.Object, ByVal e
        > > As System.EventArg s) Handles Button4.Click
        > > Dim f2 As New frmReport
        > > Me.Visible = False
        > > f2.MdiParent = ActiveForm
        > > f2.Show()
        > > End Sub
        > >
        > > What do I need to put on the "closed" event of frmReport to get
        > > frmSelect to become visible again. And have I used the best method
        > > of setting the parent form for frmReport. I had to make frmSelect
        > > invisible to get the frmMain as the active form to set it as the
        > > parent form. Otherwise a line "f2.mdipare nt = me" was trying to set
        > > frmSelect as the parent for frmReport[/color]
        >
        >
        > Use f2.mdiparent = me.Mdiparent instead.
        >
        > In frmMain, hold the references to frmSelect and frmReport in two fields.
        > Don't use the local variable f1 in mnuItem1_Click but the field in frmMain.
        > Same with frmReport: In Button4_click, raise an event notifying the
        > MDIparent that either frmReport has been opened, or that the MDIparent is to
        > open frmReport on it's own. If you do the former, pass the reference to the
        > new form along. In both cases, store the reference to frmReport in a field
        > in frmMain. Now that you have the reference, you can handle frmReport's
        > closing event. There you can reopen or reshow frmSelect. In addition,
        > handled both Form's closed event to set the references to Nothing.
        >
        >
        > Armin
        >
        >[/color]

        Comment

        • Armin Zingler

          #5
          Re: Beginners problem with multiple forms

          "mabond" <mabond@discuss ions.microsoft. com> schrieb[color=blue]
          >
          > "Armin Zingler" wrote:
          >[color=green]
          > > "mabond" <mabond@discuss ions.microsoft. com> schrieb[color=darkred]
          > > > Hi
          > > >
          > > > Can't get my head round something which I reckon should be
          > > > simple.
          > > >
          > > > My app has a main form (frmMain). MdiContainer set to true.
          > > > A menu item triggers a new form (frmSelect) whose parent is
          > > > frmMain Button on frmSelect triggers a new form (frmReport)
          > > > whose parent
          > > > also needs to be frmMain
          > > >
          > > > When frmReport loads and displays I don't want user to see
          > > > frmSelect, but I don't want to close it.
          > > >
          > > > When frmReport closes I want to re-display frmSelect so user can
          > > > make new selection for report or close Select form
          > > >
          > > > My code so far is
          > > >
          > > > On frmMain .......
          > > >
          > > > Private Sub mnuItem1_Click( ByVal sender As System.Object,
          > > > ByVal e As System.EventArg s) Handles mnuItem1.Click
          > > > Dim f1 As New frmSelec
          > > > f1.MdiParent = Me
          > > > f1.Show()
          > > > End Sub
          > > >
          > > > On frmSelect .......
          > > >
          > > > Private Sub Button4_Click(B yVal sender As System.Object,
          > > > ByVal e As System.EventArg s) Handles Button4.Click
          > > > Dim f2 As New frmReport
          > > > Me.Visible = False
          > > > f2.MdiParent = ActiveForm
          > > > f2.Show()
          > > > End Sub
          > > >
          > > > What do I need to put on the "closed" event of frmReport to get
          > > > frmSelect to become visible again. And have I used the best
          > > > method of setting the parent form for frmReport. I had to make
          > > > frmSelect invisible to get the frmMain as the active form to set
          > > > it as the
          > > > parent form. Otherwise a line "f2.mdipare nt = me" was trying to
          > > > set frmSelect as the parent for frmReport[/color]
          > >
          > >
          > > Use f2.mdiparent = me.Mdiparent instead.
          > >
          > > In frmMain, hold the references to frmSelect and frmReport in two
          > > fields. Don't use the local variable f1 in mnuItem1_Click but the
          > > field in frmMain. Same with frmReport: In Button4_click, raise an
          > > event notifying the MDIparent that either frmReport has been
          > > opened, or that the MDIparent is to open frmReport on it's own. If
          > > you do the former, pass the reference to the new form along. In
          > > both cases, store the reference to frmReport in a field in
          > > frmMain. Now that you have the reference, you can handle
          > > frmReport's closing event. There you can reopen or reshow
          > > frmSelect. In addition, handled both Form's closed event to set
          > > the references to Nothing.[/color]
          >
          > Thanks for this. The solution to setting the mdiparent worked.
          >
          > I expect the main suggestion also works but I haven't a clue how to
          > put together what you propose ...... and I should know but somehow
          > I've got a mental block with forms in vb.net.
          >
          > If I understand I should have two (invisible?) text boxes on
          > frmMain? But how do I get them to reference frmSelect and frmReport
          > as you suggest. And do I use these references to create a "new"
          > instance of my form as I would with "dim f1 as new frmSelect"
          >
          > Sorry I know I'm being "thick" but since I tried to move from vb6 to
          > vb.net I just cannot grasp how to work with my forms..... even when
          > helpful users such as yourself point me in the right direction[/color]

          No, no textboxes. Variables at class level are called "fields":

          http://msdn.microsoft.com/library/en...ypemembers.asp
          http://msdn.microsoft.com/library/en...Properties.asp


          What I meant was:

          frmMain:
          Private WithEvents ReportForm As frmReport
          Private WithEvents SelectForm As frmSelect

          Private Sub Button1_Click( _
          ByVal sender As System.Object, ByVal e As System.EventArg s) _
          Handles Button1.Click

          SelectForm = New frmSelect
          SelectForm.MdiP arent = Me
          SelectForm.Show ()

          End Sub

          Private Sub SelectForm_Clos ed( _
          ByVal sender As Object, ByVal e As System.EventArg s) _
          Handles SelectForm.Clos ed

          SelectForm = Nothing

          End Sub
          Private Sub ReportForm_Clos ed( _
          ByVal sender As Object, ByVal e As System.EventArg s) _
          Handles ReportForm.Clos ed

          SelectForm.Show ()
          ReportForm = Nothing

          End Sub
          Private Sub SelectForm_Repo rtOpened( _
          ByVal Form As frmReport) _
          Handles SelectForm.Repo rtOpened

          ReportForm = Form

          End Sub


          frmSelect:

          Public Event ReportOpened(By Val Form As frmReport)

          Private Sub Button1_Click( _
          ByVal sender As System.Object, ByVal e As System.EventArg s) _
          Handles Button1.Click

          Dim f As New frmReport
          f.MdiParent = Me.MdiParent
          f.Show()
          RaiseEvent ReportOpened(f)

          End Sub


          I didn't pay attention on frmSelect being closed. Of course, this is only
          one possible approach - such solutions are often very individual and depend
          on many black horses.


          Armin

          Comment

          • mabond

            #6
            Re: Beginners problem with multiple forms

            Armin

            Thanks. I can understand the way you've laid this out and can see the
            approach I should be using.

            I appreciate the help. Many thanks

            Regards

            Michael Bond
            information Manager
            RNID Typetalk - National Telephone Relay Service for the Deaf (UK)

            "Armin Zingler" wrote:
            [color=blue]
            > "mabond" <mabond@discuss ions.microsoft. com> schrieb[color=green]
            > >
            > > "Armin Zingler" wrote:
            > >[color=darkred]
            > > > "mabond" <mabond@discuss ions.microsoft. com> schrieb
            > > > > Hi
            > > > >
            > > > > Can't get my head round something which I reckon should be
            > > > > simple.
            > > > >
            > > > > My app has a main form (frmMain). MdiContainer set to true.
            > > > > A menu item triggers a new form (frmSelect) whose parent is
            > > > > frmMain Button on frmSelect triggers a new form (frmReport)
            > > > > whose parent
            > > > > also needs to be frmMain
            > > > >
            > > > > When frmReport loads and displays I don't want user to see
            > > > > frmSelect, but I don't want to close it.
            > > > >
            > > > > When frmReport closes I want to re-display frmSelect so user can
            > > > > make new selection for report or close Select form
            > > > >
            > > > > My code so far is
            > > > >
            > > > > On frmMain .......
            > > > >
            > > > > Private Sub mnuItem1_Click( ByVal sender As System.Object,
            > > > > ByVal e As System.EventArg s) Handles mnuItem1.Click
            > > > > Dim f1 As New frmSelec
            > > > > f1.MdiParent = Me
            > > > > f1.Show()
            > > > > End Sub
            > > > >
            > > > > On frmSelect .......
            > > > >
            > > > > Private Sub Button4_Click(B yVal sender As System.Object,
            > > > > ByVal e As System.EventArg s) Handles Button4.Click
            > > > > Dim f2 As New frmReport
            > > > > Me.Visible = False
            > > > > f2.MdiParent = ActiveForm
            > > > > f2.Show()
            > > > > End Sub
            > > > >
            > > > > What do I need to put on the "closed" event of frmReport to get
            > > > > frmSelect to become visible again. And have I used the best
            > > > > method of setting the parent form for frmReport. I had to make
            > > > > frmSelect invisible to get the frmMain as the active form to set
            > > > > it as the
            > > > > parent form. Otherwise a line "f2.mdipare nt = me" was trying to
            > > > > set frmSelect as the parent for frmReport
            > > >
            > > >
            > > > Use f2.mdiparent = me.Mdiparent instead.
            > > >
            > > > In frmMain, hold the references to frmSelect and frmReport in two
            > > > fields. Don't use the local variable f1 in mnuItem1_Click but the
            > > > field in frmMain. Same with frmReport: In Button4_click, raise an
            > > > event notifying the MDIparent that either frmReport has been
            > > > opened, or that the MDIparent is to open frmReport on it's own. If
            > > > you do the former, pass the reference to the new form along. In
            > > > both cases, store the reference to frmReport in a field in
            > > > frmMain. Now that you have the reference, you can handle
            > > > frmReport's closing event. There you can reopen or reshow
            > > > frmSelect. In addition, handled both Form's closed event to set
            > > > the references to Nothing.[/color]
            > >
            > > Thanks for this. The solution to setting the mdiparent worked.
            > >
            > > I expect the main suggestion also works but I haven't a clue how to
            > > put together what you propose ...... and I should know but somehow
            > > I've got a mental block with forms in vb.net.
            > >
            > > If I understand I should have two (invisible?) text boxes on
            > > frmMain? But how do I get them to reference frmSelect and frmReport
            > > as you suggest. And do I use these references to create a "new"
            > > instance of my form as I would with "dim f1 as new frmSelect"
            > >
            > > Sorry I know I'm being "thick" but since I tried to move from vb6 to
            > > vb.net I just cannot grasp how to work with my forms..... even when
            > > helpful users such as yourself point me in the right direction[/color]
            >
            > No, no textboxes. Variables at class level are called "fields":
            >
            > http://msdn.microsoft.com/library/en...ypemembers.asp
            > http://msdn.microsoft.com/library/en...Properties.asp
            >
            >
            > What I meant was:
            >
            > frmMain:
            > Private WithEvents ReportForm As frmReport
            > Private WithEvents SelectForm As frmSelect
            >
            > Private Sub Button1_Click( _
            > ByVal sender As System.Object, ByVal e As System.EventArg s) _
            > Handles Button1.Click
            >
            > SelectForm = New frmSelect
            > SelectForm.MdiP arent = Me
            > SelectForm.Show ()
            >
            > End Sub
            >
            > Private Sub SelectForm_Clos ed( _
            > ByVal sender As Object, ByVal e As System.EventArg s) _
            > Handles SelectForm.Clos ed
            >
            > SelectForm = Nothing
            >
            > End Sub
            > Private Sub ReportForm_Clos ed( _
            > ByVal sender As Object, ByVal e As System.EventArg s) _
            > Handles ReportForm.Clos ed
            >
            > SelectForm.Show ()
            > ReportForm = Nothing
            >
            > End Sub
            > Private Sub SelectForm_Repo rtOpened( _
            > ByVal Form As frmReport) _
            > Handles SelectForm.Repo rtOpened
            >
            > ReportForm = Form
            >
            > End Sub
            >
            >
            > frmSelect:
            >
            > Public Event ReportOpened(By Val Form As frmReport)
            >
            > Private Sub Button1_Click( _
            > ByVal sender As System.Object, ByVal e As System.EventArg s) _
            > Handles Button1.Click
            >
            > Dim f As New frmReport
            > f.MdiParent = Me.MdiParent
            > f.Show()
            > RaiseEvent ReportOpened(f)
            >
            > End Sub
            >
            >
            > I didn't pay attention on frmSelect being closed. Of course, this is only
            > one possible approach - such solutions are often very individual and depend
            > on many black horses.
            >
            >
            > Armin
            >
            >[/color]

            Comment

            • mabond

              #7
              Re: Beginners problem with multiple forms

              Armin

              Just to let you know I've finished coding with the pointers you gave me.
              Only made one change .... added a line in "frmSelcect .... button_click" to
              make the select window visible = false (rather than close).

              Everything works as desired ..... AND, more importantly, I think I've
              grasped a little bit more about how to handle forms in my apps.

              Thanks very much for your help

              Regards

              Michael Bond
              Information Manager,
              RNID Typetalk, UK National Telephone Relay Service for the Deaf.

              "Armin Zingler" wrote:
              [color=blue]
              > "mabond" <mabond@discuss ions.microsoft. com> schrieb[color=green]
              > >
              > > "Armin Zingler" wrote:
              > >[color=darkred]
              > > > "mabond" <mabond@discuss ions.microsoft. com> schrieb
              > > > > Hi
              > > > >
              > > > > Can't get my head round something which I reckon should be
              > > > > simple.
              > > > >
              > > > > My app has a main form (frmMain). MdiContainer set to true.
              > > > > A menu item triggers a new form (frmSelect) whose parent is
              > > > > frmMain Button on frmSelect triggers a new form (frmReport)
              > > > > whose parent
              > > > > also needs to be frmMain
              > > > >
              > > > > When frmReport loads and displays I don't want user to see
              > > > > frmSelect, but I don't want to close it.
              > > > >
              > > > > When frmReport closes I want to re-display frmSelect so user can
              > > > > make new selection for report or close Select form
              > > > >
              > > > > My code so far is
              > > > >
              > > > > On frmMain .......
              > > > >
              > > > > Private Sub mnuItem1_Click( ByVal sender As System.Object,
              > > > > ByVal e As System.EventArg s) Handles mnuItem1.Click
              > > > > Dim f1 As New frmSelec
              > > > > f1.MdiParent = Me
              > > > > f1.Show()
              > > > > End Sub
              > > > >
              > > > > On frmSelect .......
              > > > >
              > > > > Private Sub Button4_Click(B yVal sender As System.Object,
              > > > > ByVal e As System.EventArg s) Handles Button4.Click
              > > > > Dim f2 As New frmReport
              > > > > Me.Visible = False
              > > > > f2.MdiParent = ActiveForm
              > > > > f2.Show()
              > > > > End Sub
              > > > >
              > > > > What do I need to put on the "closed" event of frmReport to get
              > > > > frmSelect to become visible again. And have I used the best
              > > > > method of setting the parent form for frmReport. I had to make
              > > > > frmSelect invisible to get the frmMain as the active form to set
              > > > > it as the
              > > > > parent form. Otherwise a line "f2.mdipare nt = me" was trying to
              > > > > set frmSelect as the parent for frmReport
              > > >
              > > >
              > > > Use f2.mdiparent = me.Mdiparent instead.
              > > >
              > > > In frmMain, hold the references to frmSelect and frmReport in two
              > > > fields. Don't use the local variable f1 in mnuItem1_Click but the
              > > > field in frmMain. Same with frmReport: In Button4_click, raise an
              > > > event notifying the MDIparent that either frmReport has been
              > > > opened, or that the MDIparent is to open frmReport on it's own. If
              > > > you do the former, pass the reference to the new form along. In
              > > > both cases, store the reference to frmReport in a field in
              > > > frmMain. Now that you have the reference, you can handle
              > > > frmReport's closing event. There you can reopen or reshow
              > > > frmSelect. In addition, handled both Form's closed event to set
              > > > the references to Nothing.[/color]
              > >
              > > Thanks for this. The solution to setting the mdiparent worked.
              > >
              > > I expect the main suggestion also works but I haven't a clue how to
              > > put together what you propose ...... and I should know but somehow
              > > I've got a mental block with forms in vb.net.
              > >
              > > If I understand I should have two (invisible?) text boxes on
              > > frmMain? But how do I get them to reference frmSelect and frmReport
              > > as you suggest. And do I use these references to create a "new"
              > > instance of my form as I would with "dim f1 as new frmSelect"
              > >
              > > Sorry I know I'm being "thick" but since I tried to move from vb6 to
              > > vb.net I just cannot grasp how to work with my forms..... even when
              > > helpful users such as yourself point me in the right direction[/color]
              >
              > No, no textboxes. Variables at class level are called "fields":
              >
              > http://msdn.microsoft.com/library/en...ypemembers.asp
              > http://msdn.microsoft.com/library/en...Properties.asp
              >
              >
              > What I meant was:
              >
              > frmMain:
              > Private WithEvents ReportForm As frmReport
              > Private WithEvents SelectForm As frmSelect
              >
              > Private Sub Button1_Click( _
              > ByVal sender As System.Object, ByVal e As System.EventArg s) _
              > Handles Button1.Click
              >
              > SelectForm = New frmSelect
              > SelectForm.MdiP arent = Me
              > SelectForm.Show ()
              >
              > End Sub
              >
              > Private Sub SelectForm_Clos ed( _
              > ByVal sender As Object, ByVal e As System.EventArg s) _
              > Handles SelectForm.Clos ed
              >
              > SelectForm = Nothing
              >
              > End Sub
              > Private Sub ReportForm_Clos ed( _
              > ByVal sender As Object, ByVal e As System.EventArg s) _
              > Handles ReportForm.Clos ed
              >
              > SelectForm.Show ()
              > ReportForm = Nothing
              >
              > End Sub
              > Private Sub SelectForm_Repo rtOpened( _
              > ByVal Form As frmReport) _
              > Handles SelectForm.Repo rtOpened
              >
              > ReportForm = Form
              >
              > End Sub
              >
              >
              > frmSelect:
              >
              > Public Event ReportOpened(By Val Form As frmReport)
              >
              > Private Sub Button1_Click( _
              > ByVal sender As System.Object, ByVal e As System.EventArg s) _
              > Handles Button1.Click
              >
              > Dim f As New frmReport
              > f.MdiParent = Me.MdiParent
              > f.Show()
              > RaiseEvent ReportOpened(f)
              >
              > End Sub
              >
              >
              > I didn't pay attention on frmSelect being closed. Of course, this is only
              > one possible approach - such solutions are often very individual and depend
              > on many black horses.
              >
              >
              > Armin
              >
              >[/color]

              Comment

              • Armin Zingler

                #8
                Re: Beginners problem with multiple forms

                "mabond" <mabond@discuss ions.microsoft. com> schrieb[color=blue]
                > Armin
                >
                > Just to let you know I've finished coding with the pointers you gave
                > me. Only made one change .... added a line in "frmSelcect ....
                > button_click" to make the select window visible = false (rather than
                > close).
                >
                > Everything works as desired ..... AND, more importantly, I think
                > I've grasped a little bit more about how to handle forms in my apps.
                >
                > Thanks very much for your help[/color]


                You're welcome!


                Armin

                Comment

                Working...