Use VBA to open a specific Switchboard Page

APD Toronto
APD Toronto used Ask the Experts™
Hello Experts.

I'm wondering how can i use vba to open a specific switchboard page.

For example, i have 2 switchboard pages (main and admin).  on my main page i have an option "Admin Login" when clicked a dialog form opens prompting the user for password, while the main switchboard is still open.

in my dialog form i have:

If me.txtPassword <> "password" Then
   MsgBox "try again"
    'code to switch stwchboard page
   DoCmd.Close acForm, "frmAdmin"
End If

can anyone help me out please?

thank you.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2006

If you created the switchboard automatically. then the form on click events of the button call HandleButtonClick.
You could find the one that opens the admin switchboard (if it exists on the main switchboard) and call that i.e. HandleButtonClick 2

or you could just open the form

docmd.OpenForm "frmOtherSwitchboard"

Access Switchboards are table driven. The code in the OpenForm function sets a filter:

Private Sub Form_Open(Cancel As Integer)
' Minimize the database window and initialize the form.

    ' Move to the switchboard page that is marked as the default.
    Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' "
    Me.FilterOn = True
End Sub

I assume that your Admin form has not closed the switchboard, so all you need to do is set a new filter like the above code, but with the appropriate item number and argument.

If you post the contents of the switchboard table, we can assist you with the exact code.
APD TorontoSoftware Developer


OK, the below is my switchboard table.

Also, the switchboard form is called Switchboard an the login popup (where the code should go) is frmAdmin.  I tried the following, but no luck...

        [Forms].[switchboard].Filter = 3
        DoCmd.Close acForm, "frmAdmin"

SwitchboardID      ItemNumber      ItemText      Command      Argument
1      0      BBB Switchboard            Default
1      1      Daily Sellers Sign-In      3      BBSalesSigninForm
1      2      Daily Sellers Sign-out      3      BBSalesSignoutForm
1      3      Make Sales Corrections      7      openBBSalesQRY
1      4      Add New Seller      3      BBSellersEntry
1      5      Add New Location      3      BBLocationsEntry
1      6      Reports      1      2
1      7      Administrative Login      3      frmAdmin
1      8      Exit      6      
2      0      BBB Switchboard Reports      0      
2      1      Daily Sales Report      4      BBDailySalesTotalSummaryReport
2      2      Location Sales Reports      3      BBLocationSearchForm
2      3      Sellers Sales Reports      2      BBSellerGrandTotalSearchForm
2      4      Nightly Sales Report      4      BBDailySalesTotalReport
2      5      BACK to Main Menu      1      1
3      0      Admin Switchboard      0      
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Top Expert 2006

What version access are you using/

A2003 would create the HandleButtonClick. I noticed A2007 uses macros

If A2003 you could call HandleButtonClick passing in the item number. It would be in the form design

I found one graphical example here, it does talk about > 8 items but hopefully you get the jist of things
Add the following code to the Switchboard form code:

Public Sub Admin_Form()
    Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID] = 3"
    Me.FilterOn = True
End Sub

Then modify the Close action of frmAdmin:

Private Sub cmdClose_Click()
   Call Forms.Switchboard.Admin_Form
   DoCmd.Close acForm, "frmAdmin"
End Sub

Works here (Access 2007). HTH

Note DB version is actually 2003, but it is running in Access 2007. Rockiroads is right: A native Access 2007 Db ould probably work differently.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial