Dual function buttons

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I create a button that closes the form I have open and opens a
subsequent form? I want this database to flow better than continually
hitting buttons to open and close forms.
 
Oops! I think I sent an empty reply by mistake, sorry.

In the Click event of your button:

DoCmd.OpenForm "MyNextForm" 'Opens the next form
DoCmd.Close 'Closes the current form
 
Klatuu said:
Oops! I think I sent an empty reply by mistake, sorry.

In the Click event of your button:

DoCmd.OpenForm "MyNextForm" 'Opens the next form
DoCmd.Close 'Closes the current form

Actually, as written that code would likely open the second form and then close
the second form again. If you don't specify DoCmd.Close will close the
currently active object which might very well be the new form.

Either do the close first or (better) explicitly supply the object name...

DoCmd.OpenForm "MyNextForm"
DoCmd.Close acForm, Me.Name
 
You are correct, Rick. I just tested it. Specifying the form to close is
necessary. Thanks.
 

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

Back
Top