Open 1 form and close another with command button

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

Guest

Hi,

I want to be able to close 1 form and open another form that displays the
result of the first form, but I have no idea how to do it! I tried various
options in VB but with no joy.
 
ozzwald said:
Hi,

I want to be able to close 1 form and open another form that displays
the result of the first form, but I have no idea how to do it! I
tried various options in VB but with no joy.

DoCmd.Close acForm, "FormName"
DoCmd.OpenForm "OtherFormName"
 
Rick:
But if this code is part of "FormName" (the 1st form), would the 2nd
line to open "OtherFormName" still be run?

Steve
 
Steve said:
Rick:
But if this code is part of "FormName" (the 1st form), would the 2nd
line to open "OtherFormName" still be run?

Yep. The code in a form will continue executing to the end even if the very
first line is to close the form containing the code. This would not be true for
code like the following...


Sub TestSub

some code...
DoCmd.Quit
some more code...

End Sub

In the above the Quit command will definitely prevent any further lines from
executing because Access itself is being closed. A form or report however does
not have this problem from being closed.
 

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