Chapter 8. Making It Easy for Others to Use Your Database

Making It Easy for Others to Use Your Database

Chapter 8 at a Glance

In this chapter you will learn how to:

  • Create a switchboard by using Switchboard Manager.

  • Create a splash screen.

  • Set startup options.

  • Keep your application healthy.

A database created with Microsoft Office Access 2003 is a complex combination of objects and information, and the tools required to manage and manipulate them. In the first seven chapters of this book, you have learned how to work with these components to enter, organize, retrieve, and display information. You have become a database developer. You can create databases that you, or others familiar with Access, can use.

However, if information will be entered and retrieved from your database by people who aren’t proficient with Access, the information will be safer and the users happier if you take some steps to insulate them from the inner workings of Access. You need to turn your collection of objects and information into an application that organizes related tasks. Then users can focus on the job at hand, not on the program used to develop the application. With a little extra effort on your part, you can add features that make it much easier for others to access and manipulate your data, and much more difficult to unintentionally change or delete it. The most common ways to control access to a database application are through switchboards and startup options.

In this chapter, you will learn how to create and customize your own switchboard, create a splash screen, set various startup options, and use several Access utilities to help maintain the health of a database. You will be working with the GardenCo database files and a few other sample files provided on the book’s companion CD.

See Also

Do you need only a quick refresher on the topics in this chapter? See the Quick Reference entries in Chapter 8 Making It Easy for Others to Use Your Database.

Important

Important

Before you can use the practice files in this chapter, you need to install them from the book’s companion CD to their default location. See "Using the Book’s CD-ROM" for more information.

Creating a Switchboard by Using Switchboard Manager

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, salespeople for The Garden Company might use a switchboard to display a form to quickly enter orders or add new customers.

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 Switchboard Manager consists of a Switchboard Items table and one generic form containing eight hidden buttons. You can use Design view to change the location of buttons and add other visual elements (such as pictures), but 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

To be able to use a switchboard, you don’t really need to know how switchboards created with Switchboard Manager work, 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 which buttons 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 use Switchboard Manager to create a simple switchboard for the GardenCo database.

BE SURE TO start Access before beginning this exercise.

USE the GardenCo database in the practice file folder for this topic. This practice file is located in the My DocumentsMicrosoft PressAccess 2003 SBSSwitchbrdSBManager folder and can also be accessed by clicking Start/All Programs/Microsoft Press/Access 2003 Step by Step.

OPEN the GardenCo database and acknowledge the safety warning, if necessary.

  1. On the Tools menu, point to Database Utilities, and click Switchboard Manager. When Access prompts you to create a switchboard, click Yes.

    Tip

    The first page of Switchboard Manager lists any existing switchboard pages. (It lists only pages created by Switchboard Manager; if you created any pages by hand, they are not listed here.) This database doesn’t currently have any switchboard pages, but Access lists a default page to get you started.

  2. With Main Switchboard selected in the Switchboard Pages list, click Edit.

  3. In the Switchboard Name box, type The Garden Company to replace Main Switchboard, and then click Close.

    The Garden Company switchboard is now the default for this database.

  4. Click New.

    The Create New dialog box appears, in which you can name new pages you want to add to the switchboard.

  5. Type Forms to replace the text that is already selected in the Switchboard Page Name box, and then click OK.

  6. Click New again, name the new page Reports, and click OK.

    The Switchboard Manager displays your new pages.

  7. With The Garden Company (Default) selected, click Edit.

    Access displays the Edit Switchboard Page dialog box.

    Tip
  8. Click New.

    The Edit Switchboard Item dialog box appears, in which you assign properties to one of the buttons on the generic switchboard page.

    Tip
  9. In the Text box, type Forms as the text that will be the label for a button.

    The second box already contains the Go to Switchboard command, which is what you want for this example.

  10. Click the down arrow to the right of the Switchboard box, click Forms, and then click OK.

    The label and list of items in the third box vary depending on the command chosen in the second box.

  11. Click New again, type Reports in the Text box, accept the Go to Switchboard command, click the down arrow to the right of the Switchboard box, click Reports, and click OK.

  12. Click New again, and in the Text box, type Close Switchboard.

  13. Click the down arrow in the right side of the Command box, and click Run Macro.

    The label for the third box changes to Macro.

  14. Click the down arrow to display the list of macros, scroll down, click Switchboard.closeSB, and then click OK to close the dialog box and save the changes.

    Tip

    The Switchboard.closeSB macro does not come with Access; it was written specifically for this exercise. You can review this macro, and several others in the GardenCo database, by clicking Macros on the Objects bar and then opening a macro in Design view.

    Access will open the macro group called Switchboard and start running the macro at the line named closeSB.

  15. Click New again. Then in the Text box, type Close Database, click the down arrow to the right of the Command box, and click Exit Application. This command does not require a parameter, so the third box is no longer available. Click OK to close the dialog box and save the changes.

    The Edit Switchboard Page dialog box now lists the items you’ve just created.

    Tip
  16. Click Close to return to Switchboard Manager.

  17. In the list of Switchboard pages, click Forms, and then click Edit.

  18. In the Edit Switchboard Page dialog box, add these five new buttons with the following properties. (Click New to open the Edit Switchboard Item dialog box for each new entry, and then click OK to accept each item added.)

    Text

    Command

    Third box

    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

    The Garden Company

  19. Click Close to return to Switchboard Manager.

  20. Select the Reports page, click Edit, and add five buttons with these properties:

    Text

    Command

    Third box

    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

    Alphabetical List of Products

    Return

    Go to Switchboard

    The Garden Company

  21. Click Close twice to close the Edit Switchboard Page dialog box and Switchboard Manager.

  22. On the Objects bar, click Forms, and double-click Switchboard. (You might have to scroll to the right to see the form.)

    Your new switchboard opens in Form view.

    Tip
  23. Click Forms on your new Switchboard, and then click Edit/Enter Categories to look at the Categories form. When you are finished, close the form.

  24. Click Return to return to the first-level switchboard window.

  25. Click the View button to view the switchboard in Design view.

    Tip
    Tip

    The form has eight buttons and no label text.

  26. Click the first button, press to open the Properties dialog box, click the Format tab, and look at the Visible property.

    The first button and label are both set to Yes.

  27. Click the rest of the buttons in the form, one at a time.

    The Visible property of the rest of the buttons is set to No (not visible). When the form is displayed in Form view, it reads the Switchboard Items table and uses the data there to set the Visible property of the buttons and labels.

    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. Because everything needed to produce the working switchboard is contained in the Switchboard form and its underlying Switchboard Items table, you can copy or import the form and the table to any other database in which you might want a similar switchboard, modifying them as needed with Switchboard Manager.

  28. Click the Event tab, and then look at the On Click event for the buttons and labels.

    Each event is associated with a variable. In the Switchboard Items table, created by the Switchboard Manager to store information about the switchboard’s buttons, this variable is in turn associated with the command and parameters (if any) you specified. When you click a button in Form view, Access checks the On Click property, looks up the variable in the Switchboard Items table, and carries out the associated command.

  29. Close the Properties dialog box, and then close the Switchboard form, clicking Yes to save the form.

CLOSE the GardenCo database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset