Home All Groups Group Topic Archive Search About

Multiple child forms - updating the right one

Author
27 Sep 2006 9:25 PM
Kevin
I've got an mdiParent form. I open an instance of a child form like
this:

Dim frmChild as New frmCustomers
frmChild.Show()

I've got a few of these open at a time. On each frmChild I open
another form that displays customer data. When I make changes and save
the customer data, I need the updated data to show on the correct
frmChild. How do I know which form opened the customer data form and
how would I reference it?

Author
27 Sep 2006 9:30 PM
tomb
You could use a controlling class that opens all the child forms,
specifying the mdi form as its mdiform.  The controlling class can keep
track of which form has the request to open the data form, and the
controlling class can manage that also.  So when the update needs to be
done, the controlling class then handles the placement of the data into
the correct form.

Tom

Kevin wrote:

Show quoteHide quote
>I've got an mdiParent form. I open an instance of a child form like
>this:
>
>Dim frmChild as New frmCustomers
>frmChild.Show()
>
>I've got a few of these open at a time. On each frmChild I open
>another form that displays customer data. When I make changes and save
>the customer data, I need the updated data to show on the correct
>frmChild. How do I know which form opened the customer data form and
>how would I reference it?

>
Author
27 Sep 2006 9:46 PM
Kevin
Could you give me a "for instance"?


On Wed, 27 Sep 2006 17:30:20 -0400, tomb <t***@technetcenter.com>
wrote:

Show quoteHide quote
>You could use a controlling class that opens all the child forms,
>specifying the mdi form as its mdiform.  The controlling class can keep
>track of which form has the request to open the data form, and the
>controlling class can manage that also.  So when the update needs to be
>done, the controlling class then handles the placement of the data into
>the correct form.
>
>Tom
>
>Kevin wrote:
>
>>I've got an mdiParent form. I open an instance of a child form like
>>this:
>>
>>Dim frmChild as New frmCustomers
>>frmChild.Show()
>>
>>I've got a few of these open at a time. On each frmChild I open
>>another form that displays customer data. When I make changes and save
>>the customer data, I need the updated data to show on the correct
>>frmChild. How do I know which form opened the customer data form and
>>how would I reference it?
>> 
>>
Author
28 Sep 2006 12:43 AM
GhostInAK
Hello Kevin,

-CALLER-
tFormVariable.Show(me)

-DATA FORM-
if not nothing is me.owner then
'  We got a live one.
endif

-Boo


Show quoteHide quote
> I've got an mdiParent form. I open an instance of a child form like
> this:
>
> Dim frmChild as New frmCustomers
> frmChild.Show()
> I've got a few of these open at a time. On each frmChild I open
> another form that displays customer data. When I make changes and save
> the customer data, I need the updated data to show on the correct
> frmChild. How do I know which form opened the customer data form and
> how would I reference it?
>
Author
28 Sep 2006 1:44 AM
Kevin
Thanks, but the .Show(Me) function won't work with MDI Child forms,
which my form needs to be.


On Thu, 28 Sep 2006 00:43:22 +0000 (UTC), GhostInAK
<ghosti***@gmail.com> wrote:

Show quoteHide quote
>Hello Kevin,
>
>-CALLER-
>tFormVariable.Show(me)
>
>-DATA FORM-
>if not nothing is me.owner then
>'  We got a live one.
>endif
>
>-Boo
>
>
>> I've got an mdiParent form. I open an instance of a child form like
>> this:
>>
>> Dim frmChild as New frmCustomers
>> frmChild.Show()
>> I've got a few of these open at a time. On each frmChild I open
>> another form that displays customer data. When I make changes and save
>> the customer data, I need the updated data to show on the correct
>> frmChild. How do I know which form opened the customer data form and
>> how would I reference it?
>>
>
Author
28 Sep 2006 10:05 PM
Sca_Tone
Hi Kevin,
   You would add code that works in the same way the MDIParent calls
the ChildForm.

eg.
Dim frmChild as New frmCustomers
frmChild.MdiParent = Me
frmChild.Show()

>From the code above you now have an MDIParent with a linked Child as
you orginally stated.
Then you state you call another form from the child to amend customer
data.

eg.
Dim frmNewForm as new frmCustomerData
frmNewForm.Show()

**** THE FIX ****
In the customer data form you load from the child, you need to add a
    '/ ADD TO CUSTOMER DATA FORM
    Private _ParentForm As Form
    Public Property ParentForm() As Form
        Get
            Return _ParentForm
        End Get
        Set(ByVal value As Form)
            _ParentForm = value
        End Set
    End Property

Then you call the customer data form as below
    Dim frmNewForm as new frmCustomerData
    frmNewForm.ParentForm = frmChild
    frmNewForm.Show()

This allows you from the customer data form to alter the field values
on the child form
    _ParentForm.TextBox1.Text = "Joe Bloggs"

Regards,
     Tony


Kevin wrote:
Show quoteHide quote
> I've got an mdiParent form. I open an instance of a child form like
> this:
>
> Dim frmChild as New frmCustomers
> frmChild.Show()
>
> I've got a few of these open at a time. On each frmChild I open
> another form that displays customer data. When I make changes and save
> the customer data, I need the updated data to show on the correct
> frmChild. How do I know which form opened the customer data form and
> how would I reference it?
Author
2 Oct 2006 7:05 PM
Kevin
When I've tried these suggestions, other forms weren't able to access
my 'CustomerData' form. So here's what I came up with in case anybody
cares or wants to do the same thing:

'Find the correct frmCustomers that opened this form and update the
grid
        For X = 0 To (frmMain.MdiChildren.Length) - 1
            Dim tempChild As Form = CType(frmMain.MdiChildren(X),
Form)
            If tempChild.Name = "frmCustomers" Then
                Dim CallingForm As frmCustomers =
DirectCast(tempChild, frmCustomers)
                If CallingForm.txtCourseID.Text = Me.txtCourseID.Text
Then
                    CallingForm.LoadChkbox()

                    'Locate the updated record in the Grid1
                    For Y = 0 To CallingForm.Grid1.Rows.Count - 1
                        If CallingForm.Grid1.Rows(Y).Cells(0).Value =
txtCustomerNumber.Text Then
                            CallingForm.Grid1.CurrentCell =
CallingForm.Grid1.Rows(Y).Cells(1)
                            Exit For
                        End If
                    Next Y
                    Me.Close()
                    CallingForm.Show()
                    CallingForm.Grid1.Focus()
                    Exit For
                End If
            End If
        Next X

When I open the CustomerData form, I fill a textbox with the customer
number on both forms. I then look for that customer number in the
textbox on all frmCustomers. It works.



Show quoteHide quote
On 28 Sep 2006 15:05:58 -0700, "Sca_Tone" <swiftanth***@hotmail.com>
wrote:

>Hi Kevin,
>   You would add code that works in the same way the MDIParent calls
>the ChildForm.
>
>eg.
>Dim frmChild as New frmCustomers
>frmChild.MdiParent = Me
>frmChild.Show()
>
>>From the code above you now have an MDIParent with a linked Child as
>you orginally stated.
>Then you state you call another form from the child to amend customer
>data.
>
>eg.
>Dim frmNewForm as new frmCustomerData
>frmNewForm.Show()
>
>**** THE FIX ****
>In the customer data form you load from the child, you need to add a
>    '/ ADD TO CUSTOMER DATA FORM
>    Private _ParentForm As Form
>    Public Property ParentForm() As Form
>        Get
>            Return _ParentForm
>        End Get
>        Set(ByVal value As Form)
>            _ParentForm = value
>        End Set
>    End Property
>
>Then you call the customer data form as below
>    Dim frmNewForm as new frmCustomerData
>    frmNewForm.ParentForm = frmChild
>    frmNewForm.Show()
>
>This allows you from the customer data form to alter the field values
>on the child form
>    _ParentForm.TextBox1.Text = "Joe Bloggs"
>
>Regards,
>     Tony
>
>
>Kevin wrote:
>> I've got an mdiParent form. I open an instance of a child form like
>> this:
>>
>> Dim frmChild as New frmCustomers
>> frmChild.Show()
>>
>> I've got a few of these open at a time. On each frmChild I open
>> another form that displays customer data. When I make changes and save
>> the customer data, I need the updated data to show on the correct
>> frmChild. How do I know which form opened the customer data form and
>> how would I reference it?