code for closing form

S

S Kahn

On formSelect I use cmdOpen button to open another form (formData).
Appreciate any code that I can use to close the current form i.e. formSelect
when I click the cmdOpen button.
Thanks
S Kahn
 
D

DigiVamp

Not sure I'm reading from the same page but how about;
writing the code for the command button on click to be
DoCmd.Close
DoCmd.Openform "NewFormToOpen
 
A

Arvin Meyer [MVP]

S Kahn said:
On formSelect I use cmdOpen button to open another form (formData).
Appreciate any code that I can use to close the current form i.e. formSelect
when I click the cmdOpen button.

Simply open and close the forms. From a button:

DoCmd.OpenForm "Form To Open"
DoCmd.Close acForm, "Form To Close"
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
R

Rick Brandt

Arvin said:
You've got it backwards. If you close the current form, you can't open
anything from it.

Actually you can issue the DoCmd.Close first and any code lines that follow it
are still executed.
 
A

Arvin Meyer [MVP]

Actually you can issue the DoCmd.Close first and any code lines that follow it
are still executed.

Right you are. This obviously must be an exception to the general rule of VB
and VBA supposedly executing sequentially, with each statement finishing
before the next starts. I tried adding a delay loop between statements to
see if it would react as expected. It still finishes. Good catch.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
Top