Closing form

J

John

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
 
D

Douglas J. Steele

Well, the name of the current form is always going to be Me.Name, but you
don't actually need the name of the form to close it. DoCmd.Close is all you
need.
 
J

John Spencer (MVP)

It is safest to use Me.Name construct.

If you open a second form or a report or otherwise change the focus from the
original form's code module, the focus may be other than where you expect it to
be. Using

DoCmd.Close acForm, me.Name

is much safer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top