138. Modify a Form
BEFORE YOU BEGIN
137 Create a Form
117 About Manipulating Objects
139 Enter Data Using a Form
138. Modify a Form
After creating a form, you can modify it before using it to enter data into its associated table. For example, you might want to reposition a few controls so that the table data will be in a more logical order, or be visible onscreen at the same time. Or you might want to simply add a few personal touches, such as selecting the font used for data entry or for the labels.
Normally, data is entered in a form in the order in which the controls appear onscreenin other words, when a user presses Tab , the cursor automatically advances to the nearest control onscreen. However, you might prefer to change this activation order to make it easier for a user to enter data. For example, if the user has to pull data from several sources, you might want to have the cursor automatically move between just the fields being pulled from the source one, skipping any fields whose data comes from a secondary source. After the first fields are filled in, you can then have the cursor jump back to any fields you skipped the first time.
Controls An object on a form similar to those you find in a typical dialog box, such as a text box, list box, check box, or option button.
Handles Small green boxes that appear around a selected object.
| | Resize or Move Fields
As you learned in 117 About Manipulating Objects
, you must first select an object before you can resize or move it. When you click an object such as a form control, small handles
appear around its perimeter. To resize an object, drag one of these handles inward (to make the object smaller) or outward (to make it bigger). The pointer looks like a two-headed arrow when it's positioned correctly over a handle for resizing. One caution however: When you click on an object in Design
mode, typically both the object (such as a text box) and its label are selected. You probably don't want to resize the label too, so to select just the text box, press and hold the Ctrl
key and then click.
To move a selected object, click within its borders and drag. The pointer looks like a four-headed arrow when it's positioned correctly over the object for moving. Typically, you want to move both the text box and its label, so just click the object to select both, then drag to move them.
If the form is not currently displayed in Design mode, just right-click the form in the Base main window and select Edit from the context menu.
Display helpful guidelines whenever you move an object by enabling the Guides When Moving button on the Form Design toolbar.
| | Change the Background
You can change the color used for the form's background, or replace it with a texture or graphic image. Choose Format, Page
from the menu. The Page Style
dialog box appears. Click the Background
tab if needed.
To apply a color to the form's background, choose Color
from the As
list, and then click the color you want from the palette on the left.
To use a texture or other graphic as the form's background, choose Graphic
from the As
list. Then click Browse
, select the graphic you want to use, and click Open
. You're returned to the Page Style
Select where you want the graphic positioned from the options in the Type
area. The Position
option allows you to click the position in which you want the graphic placed, using the map on the right. The Area
option stretches the graphic to fill the form. The Tile
option repeats the graphic from left to right and top to bottom, to fill the form.
You'll find textures and other graphics you can use in the \OpenOffice.org\share\gallery folder.
| | Change Font
You can change the font used in labels or data entry boxes. Press Ctrl
and click the label or text box you want to change. Right-click the selected object and choose Control
from the context menu that appears. The Properties
dialog box appears.
Click the Font
button, and the Character
dialog box appears. On the Font
tab, select the Font, Typeface
, and Size
you want. On the Font Effects
tab, add special effects and select the Font color
. The preview at the bottom of the dialog box displays your changes. Click OK
. You're returned to the Properties
dialog box. If you want to select another object to change, leave it open, otherwise , click the X
to close the Properties
To change the background color used in a data entry box, select it, display the Properties dialog box, and then on the General tab, select a different color from the Background color list.
Change Activation Order
If you want to change the order in which data is entered into the various fields on a form, adjust the activation order of the form. Click any field to select it. Then click the Activation Order button on the Form Design toolbar. The Tab Order dialog box appears.
The fields appear in the list in the order in which they will be activated when a user presses Tab to move from field to field during data entry. To adjust a field's position in this list, select the field and click the Move Up or Move Down button as needed. When you're done rearranging the order of the fields, click OK.
Add a List
If you've created a single-entry table to provide a list of choices for a field in your form, you can add a list box to replace the field's normal text box on the form. First, click the field you want to replace, and then press Delete to remove it from the form.
On the Form Controls toolbar, click the List Box button. Click on the form and drag downwards and to the right to draw the list box. When you release the mouse button, the List Box Wizard appears. On the Table Selection page of the Wizard, select the table into which you typed your list from the tables shown on the right. I'm creating a form for my Drivers table. To make it easier, I decided I wanted to make a list for all the team names . So I created a single column table called Teams , and entered the various team names into the one column. Because my list source is the Teams table, I selected that in this step. Click Next .
On the Field Selection page of the Wizard, from the Existing fields list, select the field whose contents you want to use in the list. My Teams table only has one field, so the selection process was pretty easy; I choose the only field there was, which is called TeamName .
I also replaced my Rookie field with an option button that would put Yes in the field if the option was enabled by the user when entering a new record. If the option was not enabled, No would be put in the Rookie field. I used the Option Button tool on the Forms Control toolbar to draw the button, and then displayed the Control dialog box and entered Yes and No values on the Data tab. If you want this field to appear on the form with some other name, change the name shown in the Display field box. Click Next.
The Field Link page of the Wizard appears. The fields in the table that's associated with the form appear on the left. From the Field from the Value Table list, select the field in the form for which you want to substitute the list. The table for which I'm creating this form is called Drivers , so the fields in the Drivers table appear on the left. The field I want to substitute a list for is called TeamName , so I select that from the Value Table .
From the Field from the List Table list, select the field from the list table that contains the data you want to use in the list. My list table is called Teams . It has only one field, called TeamName , and that field contains the data I want the list box to show when I open it on the form. So I selected TeamName from the List Table . Click Finish . The list box is complete; when you enter data in the form, the contents of the field you selected in the source table will appear in a list, and you can choose one of its items for the current record rather than typing in the data. In my case, my Drivers form now has a list box in place of the text box for the TeamName field, and when I open that list box, the data in the TeamName field of the Teams table appears. (If you want to see my final form, it appears in the next task, 139 Enter Data Using a Form .)
Click the Save button on the Standard toolbar to save your changes to the form. Then close the form window to return to the main Base window where you can enter data into the table using your new form. See 139 Enter Data Using a Form .