By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,734 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

Closing form

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.