473,395 Members | 1,637 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,395 software developers and data experts.

Closing form

Hi

Is it possible to close a form through code from within itself without using
the form name? I just worry that form name can change and the code will stop
working.

Thanks

Regards
Nov 13 '05 #1
6 4436
rkc

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

Is it possible to close a form through code from within itself without using the form name? I just worry that form name can change and the code will stop working.


docmd.close without any of the optional arguments will close the currently
active window.

I always use docmd.close acform, me.name although I think I remember
reading here that people have had some sort of problems using me.name.
Nov 13 '05 #2

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:40*********************@news.dial.pipex.com.. .
Hi

Is it possible to close a form through code from within itself without using the form name? I just worry that form name can change and the code will stop working.

Thanks

Regards


DoCmd.Close acForm, Me.Name, acSaveNo
Nov 13 '05 #3
On May 23 2004, 02:46 pm, "rkc" <rk*@yabba.dabba.do.rochester.rr.bomb>
wrote in news:mk********************@twister.nyroc.rr.com:
I always use docmd.close acform, me.name although I think I remember
reading here that people have had some sort of problems using me.name.


If you open multiple form instances (Dim f As Form_...) as opposed to using
docmd.openform, then docmd.close may close the wrong form (IIRC, it will
close the first instance).

--
remove a 9 to reply by email
Nov 13 '05 #4
rkc

"Dimitri Furman" <df*****@cloud99.net> wrote in message
news:Xn****************************@127.0.0.1...
On May 23 2004, 02:46 pm, "rkc" <rk*@yabba.dabba.do.rochester.rr.bomb>
wrote in news:mk********************@twister.nyroc.rr.com:
I always use docmd.close acform, me.name although I think I remember
reading here that people have had some sort of problems using me.name.

If you open multiple form instances (Dim f As Form_...) as opposed to

using docmd.openform, then docmd.close may close the wrong form (IIRC, it will
close the first instance).


Right. Makes sense. I believe it was Steve Jorgensen that posted his method
for managing multiple instances of the same form using a collection object.


Nov 13 '05 #5
On May 23 2004, 10:12 pm, "rkc" <rk*@yabba.dabba.do.rochester.rr.bomb>
wrote in news:_R******************@twister.nyroc.rr.com:

"Dimitri Furman" <df*****@cloud99.net> wrote in message
news:Xn****************************@127.0.0.1...
On May 23 2004, 02:46 pm, "rkc"
<rk*@yabba.dabba.do.rochester.rr.bomb> wrote in
news:mk********************@twister.nyroc.rr.com:
> I always use docmd.close acform, me.name although I think I
> remember reading here that people have had some sort of problems
> using me.name.
>


If you open multiple form instances (Dim f As Form_...) as opposed to
using docmd.openform, then docmd.close may close the wrong form
(IIRC, it will close the first instance).


Right. Makes sense. I believe it was Steve Jorgensen that posted his
method for managing multiple instances of the same form using a
collection object.


A nice trick he posted once (thanks Steve!) is to declare a form variable
in the module of the form that will be opened in multiple instances, and
then set that variable to the instance of the form, so that the form keeps
a reference to itself, thus staying open as long as necessary.

dim f as Form_f

set f = new Form_f
set f.Self = f

where Self is a form variable declared in f's module.

All you need to do to close the instance from code is

Set f.Self = Nothing

--
remove a 9 to reply by email
Nov 13 '05 #6
John wrote:
Hi

Is it possible to close a form through code from within itself without using
the form name? I just worry that form name can change and the code will stop
working.

Thanks

Regards

docmd.Close acForm,me.Name

Will do the trick. It ensures that it will close the for regardless of name.
Nov 13 '05 #7

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

Similar topics

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...
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();
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
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: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
4
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
I am (still) relatively new to Windows applications, most of my experience has been Web based, and I am confused about what exactly happens when the Main() method is called and how to manipulate...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.