Begin at the Beginning

To create a switchboard, you'll first need to create a new form. Choose Forms from the Access bar and click the New button to launch the New Form dialog box. For a switchboard form you don't need to choose a table or query for the form's data source, just choose Design View from the list box and click OK.

You can give switchboard forms a nice title and maybe a couple of lines of text to serve as a brief explanation to users. After you've added these elements to the form, it might look similar to Figure 1-5. Any number of elements can be added to the form, including images, text, frames, fields, or other graphics. But what good is a form if it doesn't do anything?

In order for your form to do something, you'll need to add command buttons to the form. To add a new command button, choose the command button tool from the Control Toolbox and click anywhere on your form to insert the command button and start the Command Button Wizard. The first screen you'll see in the wizard (Figure 1-6) allows you to choose the type of action to perform.

We typically start designing the database's switchboard by adding two command buttons: One to launch the main data entry form (or forms as the case might be) and one to exit the database. The following steps

will create a command button to launch the MySwitchboard form for data entry:

1. Choose Form Operations from the Categories list box.

2. Choose Open Form from the Actions list box and click Next (see Figure 1-7).

3. Access displays a list of all forms available in your database. Choose the appropriate form and click Next again.

4. You can open the form and display all records or choose a specific record to display. Click Next to continue.

5. The next step in configuring your command button allows you to associate text or an image with the button. In most cases, we choose to display text on the button rather than an image. However, if you are designing a multilanguage application, you might want to stick with universally recognizable images, rather than text. Enter the text of the button in the text box, as shown in Figure 1-8, and click Next.

6. The final step in the wizard is naming your command button. Access suggests a default name of "Command" followed by a number. You should enter a meaningful name for your command button and click Finish.

While it's tempting to just accept this name and move on, it's against all common programming recommendations. You should always give your command buttons (as well as your other controls such as text boxes, labels, combo boxes, and image controls) a meaningful name. Even if you don't follow established naming conventions, such as cmdfrmPurchaseOrder), you should still ensure the name you give to your objects is meaningful, otherwise you could be left editing code that's almost unreadable because none of your objects have recognizable names. Just imagine trying to edit code for a command button that launches a particular form when you have 100 command buttons on your form and you can't remember whether you were looking for Command53 or Command91.

You can create multiple command buttons using the previous steps. When you're done, your form might look something like Figure 1-9. Save your form and close it. The next step in creating your switchboard is configuring your form to launch when you start your database. Use the following steps to configure a start-up form.

J/Start| | £ ^ ® Figure 1-9

1. Choose Startup from the Tools menu (see Figure 1-10). The dialog box that is displayed allows you to enter a title for your entire application, specify an application icon, a customized menu bar, and specify a startup form.

2. Use the drop-down box marked Display Form/Page and choose the switchboard form you created previously.

3. You can also choose whether users will see the Database Window and Status Bar or whether they will only see your custom switchboard form. If you're worried about users fiddling with the tables, forms, and reports in your database, it's often helpful to hide the Database Window. Savvy users can still access the Database Window (unless you take further steps to secure the database), but hiding the Database Window through the startup form at least makes it a little less tempting to fiddle.

4. Click OK to save your changes.

The next time you launch your database, the MySwitchboard form will automatically load for your users. You can have several switchboards within your application. For example, you might want to have a main switchboard that allows your users to explore various aspects of the application such as data entry, reporting, and application options (such as toolbar customizations or security options). When your users select the reporting button, you can launch a separate reporting switchboard with buttons for all of the reports in your application.

0 0

Post a comment