Creating a Switchboard


A switchboard appears as a hierarchy of pages containing buttons that the user can click to open additional pages, display dialog boxes, present forms for viewing and entering data, preview and print reports, and initiate other activities. For example, a salesperson might use a switchboard to display a form to quickly enter orders or add new customers.

Although switchboards are being phased out, they still work in Access 2007 and are being included in this book for people who want to transition gently to the new format. If you haven't created a switchboard in the past, and want this kind of feature, we suggest you skip this topic and investigate custom groups.

You can create switchboards by hand or with the help of Switchboard Manager. A switchboard created by hand is made up of multiple forms (pages) of your own design that are linked together by macros and Microsoft Visual Basic for Applications (VBA) code. A switchboard created with the help of the Switchboard Manager consists of a Switchboard Items table and one generic form that serves as a template when the program displays your switchboard. You can change the location of buttons and add other visual elements (such as pictures) in Design view. Unlike a switchboard created by hand, you can change the number of active buttons and the action that is performed when each button is clicked only by editing information in the Switchboard Items table.

Tip

You don't need to know how switchboards created with Switchboard Manager work to use one, but it helps to know what's going on behind the scenes in case you need to make changes. When the switchboard is opened, Access runs VBA code that reads information stored in the Switchboard Items table and uses it to set form properties that determine the buttons that are visible in the generic form. The code also assigns labels and actions to the visible buttons. If you click a button to go to a second level in the switchboard hierarchy, the code reads the table again and resets the properties for the generic form to create the page for the new level.


In this exercise, you will create a simple switchboard by using Switchboard Manager.

USE the 01_Switchboard database. This practice file is located in the Chapter09 subfolder under SBS_Access2007.

OPEN the 01_Switchboard database.


1.

On the Database Tools tab, in the Database Tools group, click the Switchboard Manager button, and then click Yes when asked whether you want to create a switchboard.

The Switchboard Manager window lists any pages created by the Switchboard Manager. Because this database doesn't currently have any switchboard pages, Access lists a default page to get you started.

2.

With Main Switchboard (Default) selected in the Switchboard Pages list, click Edit.

The Edit Switchboard Page window opens.

3.

In the Switchboard Name box, replace Main Switchboard with SBS Switchboard. Then click Close.

4.

In the Switchboard Manager window, click New.

The Create New dialog box opens.

From this dialog box, you can name new pages as you add them to the switchboard.

5.

Replace the default new switchboard page name with Forms, and then click OK.

6.

Repeat Steps 4 and 5 to create a page named Reports.

7.

With SBS Switchboard (Default) selected in the Switchboard Pages list, click Edit.

8.

In the Edit Switchboard Page window, click New.

The Edit Switchboard Item dialog box opens. From this dialog box, you can assign properties to the buttons on the generic switchboard page.

9.

In the Text box, type Forms.

This text will become a button label for the command specified in the Command box.

10.

Click the Command arrow to display the list of commands you can choose. Then click the original selection, Go to Switchboard.

With the current settings in the Edit Switchboard Item dialog box, when a user clicks the Forms button on the SBS Switchboard page, Access will display the switchboard page you specify in the Switchboard box.

11.

Click the Switchboard arrow, and then in the list, click Forms.

The Switchboard list items reflect the options for the currently selected command.

12.

In the Edit Switchboard Item dialog box, click OK.

13.

Repeat Steps 8 through 12, using the following information to create three more buttons on the SBS Switchboard page:

Text

Command

Switchboard or Macro

Reports

Go to Switchboard

Reports

Close Switchboard

Run Macro

Switchboard.closeSB

Close Database

Exit Application

(none)


When a user clicks the Close Switchboard button on the SBS Switchboard page, Access will open the Switchboard macro group, and start running the macro at the closeSB line.

Tip

The Switchboard.closeSB macro does not come with Access; it is a simple macro written specifically for this exercise. You can review the macros included with the database, by clicking Macros on the Objects bar and then opening the macro you want in Design view.

The Edit Switchboard Page window lists the four items you've just created.

14.

In the Edit Switchboard Page window, click Close to return to Switchboard Manager.

15.

In the Switchboard Pages list, click Forms, and then click Edit.

16.

Repeat Steps 8 through 12, using the following information to create five buttons on the Forms switchboard page:

Text

Command

Form or Switchboard

Edit/Enter Categories

Open Form in Edit Mode

Categories

Edit/Enter Orders

Open Form in Edit Mode

Orders

Edit/Enter Products

Open Form in Edit Mode

Products

Edit/Enter Suppliers

Open Form in Edit Mode

Suppliers

Return

Go to Switchboard

SBS Switchboard


17.

Close the Edit Switchboard Page window to return to Switchboard Manager. In the Switchboard Pages list, click Reports, and then click Edit.

18.

Use the following information to create five buttons on the Reports switchboard page:

Text

Command

Report or Switchboard

Preview/Print Catalog

Open Report

Catalog

Preview/Print Customer Labels

Open Report

Customer Labels

Preview/Print Invoices

Open Report

Invoice

Preview/Print Products

Open Report

Open Report

Return

Go to Switchboard

SBS Switchboard


19.

Close the Edit Switchboard Page dialog box and Switchboard Manager.

20.

On the Navigation Pane, under Forms, double-click Switchboard.

Your new switchboard opens in Form view.

21.

On the SBS Switchboard page, click the Forms button, and then on the Forms switchboard, click the Edit/Enter Categories button to display the Categories form.

22.

Close the Categories form, and then on the Forms switchboard, click the Return button to return to the central switchboard.

23.

Switch to Design view.

The form, which currently has only one button and its default label text, is essentially a template for your switchboard. The Switchboard table created by the Switchboard Manager contains the information needed to add the buttons and labels.

Each event is associated with a variable in the Switchboard Items table. This variable is in turn associated with the command and parameters (if any) you specified. When you click a button in Form view, Access refers to the On Click property, looks up the variable in the Switchboard Items table, and carries out the associated command.

24.

Click the button or label, and press to open the Properties dialog box.

25.

Click the Event tab of the Properties dialog box to display the On Click event for the buttons and labels.

The event that is fired when the user clicks a button is in an embedded macro. Embedded macros are a new feature in Access 2007. They are stored with a form or report, rather than in the Macros group on the Navigation Pane, and offer a higher level of security than do normal macros. To view or edit the embedded macros you would click the ellipsis (...) button.

Tip

You can reopen Switchboard Manager to add more pages or commands, and you can open the Switchboard form in Design view to add graphics or other objects.

Everything needed to produce the working switchboard is contained in the Switchboard form and its Switchboard Items table. You can create a similar switchboard by copying or importing the form and the table to any other database, and modifying them as needed with Switchboard Manager.

CLOSE the Property sheet, save and close the Switchboard form, and then close the 01_Switchboard database.




MicrosoftR Office AccessT 2007 Step by Step
MicrosoftR Office AccessT 2007 Step by Step
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 127

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net