Opening & Closing Forms with Switchboard

dbh139

New Member
Joined
Jan 26, 2003
Messages
33
I am new to using switchboards and am having some difficulty going between forms and my switchboard. I have created a macro which successfully goes from a data form and opens the switchboard, however it does not let me go between the two with my control buttons after I click on it the first time. I am trying to format my forms and switchboard so that when I open a form the switchboard closes, and when I click my "return to switchboard" button on my data form that this form closes and my switchboard opens. I don't understand why it works the first time I use the button, but then seems to stop functioning. Does anyone know how I need to set up the macro or how i need to format my forms?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Yes, this can be easily done with an extra line of code in your Macro's procedure (though limited, Macros are a great way to start learning VBA):
-Goto your code window and find the procedure for the Command Button's Click event
-You see where it says something like
Code:
Docmd.OpenForm stDocName,,stLinkCriteria

Directly AFTER this line, write:
Code:
Docmd.close acForm, "The_Name_Of_The_Form_You're_Trying_To_Close"

Of course, do this for both the Switchboard and the Data Entry form buttons.
 
Upvote 0
First of all, when I am using my switchboard, it automatically closes whenever I open a data form. When going back is when I am having the problem. I have inserted the line in the code, however I am not sure If I am inserting it in the correct place. Here is all i see in the code for the button. . .

Option Compare Database

Private Sub Command74_Click()
DoCmd.Close acForm, "Display Data Entry Form"
End Sub

Private Sub Command73_Click()
DoCmd.Close acForm, "Display Data Entry Form"
End Sub

Have I done this correctly? It still doesnt seem to work. . . Let me know if you think I need to move this line of code or if I am having some other issue. Thanks so much for your help on this issue.
 
Upvote 0
Try:

Code:
Private Sub Command74_Click() 
DoCmd.Open "Your_Switchboard"
DoCmd.Close acForm, "Display Data Entry Form" 
End Sub
 
Upvote 0
I tried that code and I still cannot seem to get it to close. . . The main reason I need it to close is because I have many forms that run of the same query and I am not able to open them if the forms do not close within the menu structure. . . here is the code where I tried your recommendation. . .

Option Compare Database

Private Sub Command74_Click()
DoCmd.Open "Switchboard"
DoCmd.Close acForm, "Display Data Entry Form"
End Sub

Private Sub Account_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub Check105_Click()
DoCmd.Open "Switchboard"
DoCmd.Close acForm, "Display Data Entry Form"
End Sub

Private Sub Command73_Click()
DoCmd.Open "Switchboard"
DoCmd.Close acForm, "Display Data Entry Form"
End Sub

Private Sub Return_to_Main_Menu_Click()
DoCmd.Open "Switchboard"
DoCmd.Close acForm, "Display Data Entry Form"
End Sub


I also don't understand exactly why I have so many commands related to the same control button?? Is there any other way to work out my problem? I must be doing something wrong.
 
Upvote 0
Wait a second...Is "Display Data Entry Form" the name of the form that you're trying to close? This doesn't really sound like the name of a form, more like a caption to a control. So make sure that the names of both your Switchboard and your data entry form are correct in your code. And is the code that you pasted in a form module? This would mean that you have several command buttons on the same form that do the exact same thing?
I also don't understand exactly why I have so many commands related to the same control button??
Your code reads the opposite; you have one command related to several different control (command) buttons. I'm not sure exactly what your reasoning was, but surely you only want one command button to perform this open/close task?

So:
Code:
Private Sub Your_Command_Button_On_Click()
     DoCmd.Open Form, "The_Exact_Name_Of_Your_Switchboard",,,stlinkcriteria
     DoCmd.close acform, "The_Exact_Name_Of_The_Form_You're_On"
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,530
Messages
6,160,351
Members
451,639
Latest member
Kramb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top