Close a FORM from a different FORM

  • Thread starter Thread starter Chip
  • Start date Start date
C

Chip

Hi Again from Oklahoma!!

I am new to ACCESS and VB but i am needing to press a button on FORM1 to
Close FORM2. I just do know where to start with this one. I know it is
very simple but i cannot figure it out.

As always, THANKS IN ADVANCE!! (I never know if my thank-you's ever reach
the person after the fact...)
 
The context for this is often that FORM1 is opened by FORM2, and you
don't want the user to return to FORM2 when FORM1 is closed. Josh's
solution is straghtforward and works fine as long as FORM1 is always
opened by FORM2. If FORM1 may also be opened from FORM3, FORM4, etc.,
you need either to pass it the name of the opening Form in some way
(OpenArgs is often the easiest), or use a Function to switch Forms.

In the on click event of your button in FORM1 add this code:

docmd.Close acForm, "FORM2"


Please respond to the Newsgroup, so that others may benefit from the exchange.
Peter R. Fletcher
 
Back
Top