473,794 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4464
rkc

"John" <jo**@nospam.in fovis.co.uk> wrote in message
news:40******** *************@n ews.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.in fovis.co.uk> wrote in message
news:40******** *************@n ews.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.dabb a.do.rochester. rr.bomb>
wrote in news:mk******** ************@tw ister.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*****@cloud9 9.net> wrote in message
news:Xn******** *************** *****@127.0.0.1 ...
On May 23 2004, 02:46 pm, "rkc" <rk*@yabba.dabb a.do.rochester. rr.bomb>
wrote in news:mk******** ************@tw ister.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.dabb a.do.rochester. rr.bomb>
wrote in news:_R******** **********@twis ter.nyroc.rr.co m:

"Dimitri Furman" <df*****@cloud9 9.net> wrote in message
news:Xn******** *************** *****@127.0.0.1 ...
On May 23 2004, 02:46 pm, "rkc"
<rk*@yabba.dabb a.do.rochester. rr.bomb> wrote in
news:mk******** ************@tw ister.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
5824
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 MDI child window. My application does certain logic when the user actually closes the MDI child form by clicking the "X" in the upper right hand. My application, however, should not execute this logic if the user closes the MDI parent. I...
6
3230
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
2204
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
4030
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...
3
2778
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 the value to False, but I would have expected it to be False on entry. TIA Charles
2
3023
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 and then attempts to close the window (either via my custom 'Close' box or by clicking the close 'X' in the upper right window corner), the validation event still triggers and it tells the user that they have invalid data. Which of course means...
4
3008
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 another when its form Closing routine is run? I guess what I'm asking is will that work. If one form sets e.cancelled to true will e.cancel be true when the next form receives a closing event?
14
3367
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 I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
19
3228
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 these Validating Events are also fired when either the child form or the main (parent) form Close icon is clicked. And I need for these events to know if they are being invoked because the app (or child window) is being closed. I have set a boolean...
2
4234
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 forms opening & closing. An example of this issue is as follows. I have a logon form open as the first thing. The main functional form opens when a user has successfully logged on. From the main form, a user should be able to logout which will...
0
9518
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
10433
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10161
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
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
5436
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.