Create push-button menus


Tip
It's easy to create a database menu form with push-button controls. You can start from scratch or copy a menu from a sample database and customise it. I often start with a blank form, change it a bit, then pirate some buttons from another menu. Next, I change the code attached to the buttons and call the form Menu -- unimaginative but easy to identify.
These steps apply to Access. For other databases, visit US PC World Online at http://www.pcworld.com/hereshow.html.
1.Create a new blank form: in the database window, select the Forms tab, then click the New button. In the New Form dialogue box, leave Design View highlighted and click OK. You don't need to choose a table or a query for the form.
2. The grid area that appears represents the background of your menu. To resize the grid area, click and drag its lower right corner.
3. Change some of the form properties to make the form look more like a dialogue box and less like a window for viewing records. Right-click the box to the left of the horizontal ruler, choose Properties, and select the Format tab. Set Scroll Bars to Neither, Record Selectors to No, and Navigation Buttons to No, as in the figure.
4. To change the background colour of the form, leave the Properties box open and click the Detail bar on the form. Make sure the Format tab is selected, and click the Back Color line. Click the ... button that appears at the end of the line to open the Color dialogue box. Select a shade, then click OK. Click the Detail bar again to see how your choice looks.

5. Before you start adding push buttons, click the Label tool in the toolbox, drag the mouse to create a box for the title, then enter a title in the box. If you decide that using an appropriate file name for the form is enough, select File--Save and enter a name like Menu.
You can add a graphic to a menu form. Click the Image button in the toolbox, drag the mouse to create a box for the image, then select a graphic from the Insert Picture dialogue box. Depending on how your software was installed, you may find interesting pictures in the c:\msoffice\clipart directory or in c:\msoffice\access\bitmaps\dbwiz.
6. Click the Command button in the toolbox, and drag the mouse to create a push button on the form. If the Control Wizard button is depressed, you'll get help from the Command Button Wizard, which offers lots of options: actions for opening forms and reports, moving through records, and other common tasks. You can also show a text label or a picture on the button.
7. To copy a button you've already placed on the form, click the button and select Edit--Duplicate. Double-click the text on the new button to edit it or change its Caption property. If you copy a button, change its On Click property: in the Command Button dialogue box, select the Event tab, click the ... button at the end of the line, and select Macro Builder in the Choose Builder dialogue box. (It may be quicker to use the Command Button Wizard again.)
You can also copy macro buttons from one form to another. Both databases must include the macro that's attached to the command button being copied. Open the form that contains the button you want to copy, go into Design mode, select the button and click the Copy button on the main toolbar. Go back to your menu form in Design mode, click the Paste button, then drag the copied button to wherever you want it. This trick works when you don't need to change the action that belongs to the Command button.
8. Select File--Save; name the form Menu.
9. To open the menu form automatically when you open the database, choose Tools--Startup, click the Display Form drop-down box, select Menu and click OK. You can also use an autoexec macro to open the form.
- Celeste Robinson


Category: Data management
Issue: Apr 1997
Pages: 170-174

These Web pages are produced by Australian PC World © 1997 IDG Communications