473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Closing forms opened with show when parent form closes

RD
Dim myfrm as new frmb
myfrm.show()

Dim myfrm2 as new frmc
myfrm2.show

Opens two forms from a butom located on forma

when I close forma I would like both form myfrm and for myfrm2 to close
automatically

Can anyone tell me how or point me to some sample code that does this type
of thing?

Thank you for any help

Bob


Nov 20 '05 #1
3 1284
"RD" <no****@nospam.net> schrieb
Dim myfrm as new frmb
myfrm.show()

Dim myfrm2 as new frmc
myfrm2.show

Opens two forms from a butom located on forma

when I close forma I would like both form myfrm and for myfrm2 to
close automatically

Can anyone tell me how or point me to some sample code that does this
type of thing?


Form A has a closed event. Handle the event (or overwrite OnClosed) and
close the other forms by calling their Close methods.

You can also make form A the owner of the other forms, so they be will
automatically closed when form A is closed, but the owned forms (B and C)
will always be in front of the owner form (A). In addition, the owned forms
will automatically be minimized when the owner form is minimized. The might
be useful - but if you don't want this behavior you can go the first way.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
RD
Thanks Armin,
But that is exactly what I can't figure out how to do.

The Dim for the myFrm as new frmb is in thebutton_click event so the
instance that is open (myfrm) can not be referenced directly from within the
formA's closed event. It is out of scope because Myfrm is private to the
button_click event. So how do you refer to it in the code in the closed
event?
To refer or not to refer, that is the question ;-)

Bob

"Armin Zingler" <az*******@freenet.de> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
"RD" <no****@nospam.net> schrieb
Dim myfrm as new frmb
myfrm.show()

Dim myfrm2 as new frmc
myfrm2.show

Opens two forms from a butom located on forma

when I close forma I would like both form myfrm and for myfrm2 to
close automatically

Can anyone tell me how or point me to some sample code that does this
type of thing?
Form A has a closed event. Handle the event (or overwrite OnClosed) and
close the other forms by calling their Close methods.

You can also make form A the owner of the other forms, so they be will
automatically closed when form A is closed, but the owned forms (B and C)
will always be in front of the owner form (A). In addition, the owned

forms will automatically be minimized when the owner form is minimized. The might be useful - but if you don't want this behavior you can go the first way.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
"RD" <no****@nospam.net> schrieb
Thanks Armin,
But that is exactly what I can't figure out how to do.

The Dim for the myFrm as new frmb is in thebutton_click event so
the instance that is open (myfrm) can not be referenced directly from
within the formA's closed event. It is out of scope because Myfrm is
private to the button_click event. So how do you refer to it in the
code in the closed event?
To refer or not to refer, that is the question ;-)


Declare the variables at class level (= as fields of the class; named
"Module Scope" in the following chapter):

http://msdn.microsoft.com/library/en...copeLevels.asp

see also:
http://msdn.microsoft.com/library/en...odsToClass.asp
http://msdn.microsoft.com/library/en...fVBSpec7_5.asp

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

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

Similar topics

2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
2
by: Mark Reed | last post by:
Hi All, My database has a macro which opens up a table. A text file is then pasted into the table and the then closed manually. Once closed, I then have another macro which runs certain queries to...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
3
by: Andrew | last post by:
I get a Null Reference Exception if I close a non-modal dialog (that is, a form opened with Show()) when a selection is made from a ComboBox. The error message refers to Unsafe Native Methods, but...
6
by: Gary Miller | last post by:
Does anyone know how to detect a modeless form on closing by the form that invoked the modeless form? form.Show();
10
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...
3
by: Oenone | last post by:
I'm writing an application with various MDI child forms. In the Closing event of many of the forms, I have code that asks the user whether he is sure he wants to close the form, because it...
4
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
21
by: Dan Tallent | last post by:
In my application I have a form (Customer) that I want to be able to open multiple copies at once. Within this form I have other forms that can be opened. Example: ZipCode. When the user enters...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.