Closing form

  • Thread starter Thread starter John
  • Start date Start date
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
 
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.
 
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.
 
Back
Top