Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command Button to both Open and Close

Status
Not open for further replies.

Badjoojoojen

Technical User
Apr 5, 2005
7
US
I have 2 switchboards, a Main that has 2 command buttons, 1 to open my tracking form and another to open a second switchboard, Reports Menu. When I click on the command buttons, the appropriate form is open, but the switchboard remains open as well. How can I code the command buttons to open the new form and close the current form (the switchboard)?

Thanks!
 
docmd.close
docmd.openform("form name")

You can also hide your switchboard by toggling the visible property.
 
Code:
docmd.close
docmd.openform("form name")
This will work but it is not the correct way. You need to open the second form first then close the current form. The difference will understand when you open the second form while passing some arguments from the first form. Access will complain that it can't find ....
Code:
docmd.openform("form name")
docmd.close("form name")

________________________________________
Zameer Abdulla
Visit Me
A child may not be able to lift too much.
But it can certainly hold a marriage together
 
For the DoCmd.Close, I'd be even more specific about the object you are closing

DoCmd.Close acForm, "Form name"

You never now, two open objects may have the same name. Especially if you've used the awful MS wozards included with the product.

Stewart J. McAbney | Talk History
 
Also I've noticed if you set a breakpoint in your code and come to a DoCmd.Close while stepping through, it may close the whole DB, not just the form. Best to be as specific as possible.

Ken S.
 
If you used the switchboard wizard then you'll need to create a function that will 1. Open the new form and 2. Close the existing Switchboard. Then you need to Edit the 1st Switchboard to call the Function and not the action to only open the Form.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top