Close active form

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Is it possible to create code that I can assign to command button on my
various forms that closes the form the button is on and then opens my
"mainform"? I am trying to avoid having to write a macro for every single
form in my application.
 
Normally when a form opens another form, both stay open and when you close
the second form the previous form reappears.

-Dorian
 
But in some instances, you might close or hide the previous form.

To close the current form, use:

docmd.close acform, me.name

Follow that up with:

If application.allforms("mainform").isloaded then
forms("mainform").visible = true
forms("mainform").setfocus
else
docmd.openform "mainform"
endif

Put all that code in the click event of a command button.

HTH
Dale
 
Hi ,

How is everything going? Please feel free to let me know if you need any
assistance.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top