473,767 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple child forms - updating the right one

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?
Sep 27 '06 #1
6 1716
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?

Sep 27 '06 #2
Could you give me a "for instance"?
On Wed, 27 Sep 2006 17:30:20 -0400, tomb <to**@technetce nter.com>
wrote:
>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?

Sep 27 '06 #3
Hello Kevin,

-CALLER-
tFormVariable.S how(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?

Sep 28 '06 #4
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
<gh*******@gmai l.comwrote:
>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?
Sep 28 '06 #5
Hi Kevin,
You would add code that works in the same way the MDIParent calls
the ChildForm.

eg.
Dim frmChild as New frmCustomers
frmChild.MdiPar ent = 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.Pare ntForm = frmChild
frmNewForm.Show ()

This allows you from the customer data form to alter the field values
on the child form
_ParentForm.Tex tBox1.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?
Sep 28 '06 #6
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.MdiChi ldren.Length) - 1
Dim tempChild As Form = CType(frmMain.M diChildren(X),
Form)
If tempChild.Name = "frmCustome rs" Then
Dim CallingForm As frmCustomers =
DirectCast(temp Child, frmCustomers)
If CallingForm.txt CourseID.Text = Me.txtCourseID. Text
Then
CallingForm.Loa dChkbox()

'Locate the updated record in the Grid1
For Y = 0 To CallingForm.Gri d1.Rows.Count - 1
If CallingForm.Gri d1.Rows(Y).Cell s(0).Value =
txtCustomerNumb er.Text Then
CallingForm.Gri d1.CurrentCell =
CallingForm.Gri d1.Rows(Y).Cell s(1)
Exit For
End If
Next Y
Me.Close()
CallingForm.Sho w()
CallingForm.Gri d1.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.

On 28 Sep 2006 15:05:58 -0700, "Sca_Tone" <sw**********@h otmail.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.MdiPa rent = 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.Sho w()

**** 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.Pare ntForm = frmChild
frmNewForm.Show ()

This allows you from the customer data form to alter the field values
on the child form
_ParentForm.Tex tBox1.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?
Oct 2 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1617
by: tdmailbox | last post by:
I have added search buttons to some access fomms. I have a seach button in both the parent and the child form. My issue is that when I search for a last name in the last_name field of the child form I want to search for that last_name accross all parent forms, flipping to any parent form that has a child record with the right last_name. Is there a reasonible way to do this?
8
4938
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender, System.EventArgs e) { MessageBox.Show("keyboard button pressed!"); } Following is the code to load the frmTestBaby
3
4027
by: Roland Wolters | last post by:
Hi, I have parent-form that displays a list of product-details. When the user clicks on a line a child form opens that displays further details. The user then can alter these details. On the child-form is a button that the user uses to update the data in the database. At the click of this button I want to close the child-form AND update the list displayed on the parent-form. At thsi point the user needs to re-load the parent-form but...
3
3212
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing MDI container form) or if the MDI child form's Visible property is set to False (after the MDI child form was shown). This is an enormous problem for my app because I must show different MDI child forms based on the state of my application and many of the...
10
4029
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
7
3113
by: Siv | last post by:
Hi, I have an MDI application that uses a generic "ShowPage" routine in a module that is called when I want to display a child form. The basic idea is that in the module I have declared each form as follows: Friend F0 As frmMain Friend F1 As frmStart Friend F2 As frmSearch Then in my ShowPage routine (which is passed a string "pageToShow" which is the name of the form I wish to open), I first check to see if we already have an instance...
7
2737
by: Jeff | last post by:
I plan to write a Windows Forms MDI application for a medical office. Users must be able to select a patient and view related information on multiple forms; with1-4 forms opened at the same time for the same patient; each form showing a different type of patient-related information. After viewing information for one patient (say on 3 forms opened simultaneously), users want the ability to select another patient. Upon selection of another...
2
4902
by: Mario | last post by:
Hi, I am trying to create an application with multiple windows forms. The problem that I have is that after creating the window forms, I do not know how to open formN after closing Main form. Each form is in its own class. What I want to do is the following: 1. Click a button on Main menu. 2. Close main menu ( I would use hide if possible) 3. Open form2
0
2044
by: emalcolm_FLA | last post by:
Hello and TIA for any help with this non profit Christmas assistance project. I have an applicant (app history) and child (child history) tables (4 total). I need to grab the next available (in house case number, appt date and time) for the applicants yearly history and the childs yearly history and then print a report with the applicants info and this in house case number. The forms are linked with ID_app (from the applicant table).
0
9571
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9405
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5280
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5424
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3930
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.