Returning to the switchboard

teiben

Registered User.
Local time
Today, 23:48
Joined
Jun 20, 2002
Messages
462
Help! I'm sure this is something stupid, but I can't figure it out. (usine 97 / xp)
I have a main switchboard, which calls switchboard A, which has form A on it. I have a command button which closes form A and returns the user back to switchboard A, but I need it to go back to the main switchboard. (Switch was created using Switchboard manager).

I've tried, searching throught the help here & I've also tried

Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click

DoCmd.OpenForm "Switchboard", acNormal, , , acFormEdit, acNormal
DoCmd.close

'Docmd.Close

Exit_cmdClose_Click:
Exit Sub

Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click

End Sub

Any ideas?
 
One trick you can try.... create a command button that closes the form you are trying to close. Copy the code that makes it work and paste it where you need it such as the onclose event of a form :D
 
That was the first thing I tried. All it does is put a docmd.close, which close and returns to the last switchboard, or switch A - not the main one.
 
Well I guess I am not sure how switchboards work since I never use them. I think you will find that most people here will advise you to stay away from them and make your own out of forms that you can make look and act anyway that you want them to. I will have a look at switchboards though and see. Why dont you have a go at making your own and we can compare notes.
 
That's not an option for me (security is in the switchboard table). I'm sure there is someway to refer to it via code
 
This will close the switchboard and open it again which will return you to the primary page. Change the terms to suit your application:

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

'closes the switchboard
DoCmd.Close acForm, "Switchboard"

'Opens the switchboard
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Switchboard"
DoCmd.OpenForm stDocName, , , stLinkCriteria

'Close the form with the command button you are clicking
DoCmd.Close acForm, "YourForm"

Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub
 
Last edited:
I tried this and it closes all switchboards & form I'm in
 
Nevermind, I had an extra docmd.close in there. Thank you! I would have never guessed run DoCmd.Close acForm, "Switchboard"
then a DoCmd.OpenForm stDocName, , , stLinkCriteria. I suspected there was some special way to refer to the different levels of the switchboard.
 

Users who are viewing this thread

Back
Top Bottom