Writer Guide

15

Chapter
Using Forms in WriterThis PDF is designed to be read onscreen, two pages at atime. If you want to print a copy, your PDF viewer shouldhave an option for printing two pages on one sheet ofpaper, but you may need to start with page 2 to get it toprint facing pages correctly. (Print this cover page
separately.)CopyrightThis document is Copyright © 2005–2010 by its contributors as listed
in the section titled Authors. You may distribute it and/or modify it
under the terms of either the GNU General Public License, version 3 orlater, or the Creative Commons Attribution License, version 3.0 or
later.
All trademarks within this guide belong to their legitimate owners.

Authors
Tara Hess
Sigrid Kronenberger
Iain Roberts
Janet Swisher
Jean Hollis Weber
Claire Wood
Michele Zarri

Feedback
Please direct any comments or suggestions about this document to:authors@documentation.openoffice.org

Publication date and software version
Published 25 March 2010. Based on OpenOffice.org 3.2.

You can download
an editable version of this document fromhttp://oooauthors.org/english/userguide3/published/

Contents
Copyright............................................................................................... 2
Introduction to forms.............................................................................4
When to use forms.................................................................................4
Alternatives to using forms in Writer..................................................5
Creating a simple form..........................................................................5
Create a document.............................................................................. 5Open the form toolbars.......................................................................5
Activate design mode..........................................................................6
Insert form controls............................................................................6
Configure controls..............................................................................7
Use the form....................................................................................... 8
Form controls reference......................................................................... 8
Example: a simple form........................................................................ 14
Create the document........................................................................14
Add form controls.............................................................................14
Configure form controls....................................................................17
Finishing touches.............................................................................. 19
Accessing data sources........................................................................20
Creating a database..........................................................................20
Accessing an existing data source....................................................23
Creating a form for data entry..........................................................24
Entering data into a form..................................................................26
Advanced form customization..............................................................27
Linking a macro to a form control....................................................27
Read-only documents........................................................................28
Fine-tuning database access permissions.........................................28
Form control formatting options.......................................................29
XForms................................................................................................. 30

Using Forms in Writer3

Introduction to forms
This chapter covers the use of forms within Writer documents. Most of
the information here also applies to forms in other OpenOffice.org
components, but there are some differences.
The chapter presents information on using forms in four main sections:setting up a basic form, an example for creating a form, linking a form
to a data source, and finally some advanced techniques.
OpenOffice.org forms cover a lot of ground and not everything is
included here. Notable omissions are using forms in HTML documents
and writing macros to link to form controls.

When to use forms
A standard text document displays information: a letter, report, or
brochure, for example. Typically the reader may edit everything or
nothing in the document. A form has sections that are not to be edited,and other sections that are designed for the reader to make changes.
For example, a questionnaire has an introduction and questions (which
do not change) and spaces for the reader to enter answers.
OpenOffice.org offers several ways to enter information into a form,
including check boxes, option buttons, text boxes, pull-down lists, andother items, collectively known as form controls.
Forms are used in three ways:• To create a simple document for the recipient to complete, suchas a questionnaire sent out to a group of people who fill it in andreturn it.
• To link into a database or data source and allow the user to enter
information. Someone taking orders might enter the information
into a database using a form.
• To view information held in a database or data source. A librarianmight call up information about books.
Using forms to access a database offers a fast and easy way to build up
complex graphical front ends. Your form can include not only the fields
that link up to the data source but also text, graphics, tables, drawings
and other elements.
A typical way to use a simple form is:1) You design the form, then save it when you are happy with it.
2) You send the form to others (for example, by email).
4

Using Forms in Writer3) They fill in the form, save it and send it back to you.
4) You open the form and see what their answers are.
Tip

By using a data source, or setting a form to update over theweb, you can automatically gather data. However, both of thoseare more complex and you might prefer to keep things simple.

Alternatives to using forms in Writer
In OpenOffice.org 3.x, the Base component provides an alternative way
to access a data source. There are a lot of similarities between forms in
Base and Writer, but one may be better for a particular task than theother. Base is appropriate only if the form accesses a data source; youwould not use it for simple forms.
Most other OpenOffice.org components—Calc, Impress, and Draw—
also support forms in almost the same way that Writer does.

Creating a simple form
This section explains how to create a simple form without any links to adata source or database and without advanced customization.

Create a document
There is nothing special to be done when creating a document to use
as a form. Create a new Writer document with File > New > Text
document.

Open the form toolbars
Two toolbars control form creation: Form Controls and Form Design.
Select View > Toolbars > Form Controls and View > Toolbars >Form Design to show them both. The Form Controls toolbar has abutton for each of the most commonly used types of control.
You can also open the Form Design toolbar from the Form Controls
toolbar. Some of the less commonly used controls are on a third toolbar—More Controls—also opened from the Form Controls toolbar.
You can dock these toolbars in different places on the Writer window,or leave them floating. Figure 1 shows the three toolbars floating.
See “Form controls reference” on page 8 for descriptions of the toolson these toolbars.
Creating a simple form

5

Figure 1: The Form Control, More Controls and Form Design Toolbars

Activate design mode
Click the Design Mode On/Off buttonon the Form Controls
toolbar to turn design mode on. (Click it again when you want to turn itoff.) This activates the buttons for inserting form controls and selects
controls for editing.
When design mode is off, the form behaves as it would for the end user.
Buttons can be pressed, check boxes selected, list items selected, andso on.

Insert form controls
1) To insert a form control into the document, click the control’s icon
to select it. The mouse pointer changes to look like this:2) Click in the document where you want the control to appear. (Youcan move it later.)3) Holding the left mouse button down, drag the control to size it.
Some controls have a fixed size symbol followed by the name of
the control (for example, Check Box or Option Button).
4) The control button remains active, so you can insert several
controls of the same type without needing to go back to thetoolbar.
5) To change to another tool, click its icon on the toolbar.
6

Using Forms in Writer6) To stop inserting controls, click on the Select buttonon theForm Controls toolbar, or click on any of the controls you havejust inserted. The mouse pointer changes back to its normal
appearance.
Tip

Note

Holding down Shift when creating a form control makes thecontrol square. If you press Shift when resizing an existing
control, its proportions are kept the same.
When you insert a group box, list box, or combo box, a wizard
is launched to guide you through the setup. If you prefer not to
run the wizard, click the Wizards On/Off buttonon theForm Controls toolbar.

Configure controls
After inserting the controls, you need to configure them to look andbehave as you want. Right-click on a form control within yourdocument and select Control from the pop-up (context) menu to open
the Properties dialog box for the selected control. Double-clicking on aform control also opens this dialog box.
The Properties dialog box has three pages: General, Data, and Events.
For simple forms, only the General page is of any interest. On this page
you can set the look and feel of the control. See “Configure form
controls” on page 17 and “Form control formatting options” on page 29
for more information, and the descriptions in the Help for details.
Configuration for use with a database is discussed in “Creating a form
for data entry” on page 24.
The fields on this dialog box vary with the type of control. For example:• Some controls have visible labels, such as Push Button and Option

Button. The label text can be set.
• The List Box contains a list of options to choose from. Set these in
the List entries box.
Notice the scroll bar in this dialog box. You can use the scroll bar or
enlarge the dialog box to see additional fields.

Creating a simple form

7

Figure 2: Example of the Properties dialog box
for a form control

Use the form
To use the form, leave design mode by clicking the Design Mode
On/Off button

to deactivate it. Save the form document.

Form controls reference
Form Control toolbar
SelectSelects a form control to perform some otheraction on it.

Design mode on/off

Toggles between design mode on (to edit
forms) and design mode off (to use forms).

ControlForm

8

Launches form control properties dialog box.
This dialog box can be kept open as different
controls are selected.
Launches form properties dialog box,
controlling properties for the form as a whole,such as which data source it connects to.

Using Forms in WriterForm Control toolbar
Check Box

A box that can be selected or deselected on theform. You can label the box.

Text Box

A control to create a box into which the form
user can type any text.

Formatted Field

Push Button

Option Button

List Box

Combo BoxLabel Field

More Controls

Form controls reference

A control allowing numeric formatting options.
For example, you can set maximum andminimum values for the number entered, or thenumber type (decimal places, scientific,
currency).
Creates a button that can be linked to a macro.
The label is the name that appears on the
button.
Creates an option button (also known as aradio button). When multiple buttons aregrouped together, only one can be selected at atime. The easiest way to group multiple buttons
is to use the Group Box button on the MoreControls toolbar, with wizards enabled.
Creates a list of options as a pull-down menu
that the user can choose from. If wizards areon, creating a list box launches the List Box
Wizard. This wizard is only useful if your form
is linked to a data source.
If the form is not linked to a data source, turnwizards off and create an empty list box. Thenclick the control button and, in the List Entries
option on the General tab, enter the options
you want to appear on the list.
As with a List Box, you set up a list of choices.
In addition, a panel at the top either displays
the choice made or allows the form user to typein something else. This works the same as theList Box.
A text label. The difference between this andjust typing on the page is that, as a control, you
can link a label field to macros so, for example,
something happens when the mouse passes
over it or clicks on it.
Launches the More Controls toolbar.

9Form Control toolbar
Form Design

Wizards On/Off

Launches the Form Design toolbar, which canalso be opened with View > Toolbars > Form
Design.
Some form controls (List Box and Combo Box)have optional wizards. If you do not want the
wizard to launch when you create one of thesecontrols, use the Wizards On/Off button toswitch wizards off.

More Controls toolbar
Spin Button

Scrollbar

Image Button

Image Control

Date Field

Time Field

10

Allows form users to choose a number bycycling through the list of numbers. You canspecify maximum, minimum, default, and thestep between numbers.
This control is not commonly used in Writer, as
the number is not displayed. In Calc, however,a Data tab appears on the Control Properties
dialog box, so you can link the spin button to acell.
Creates a scrollbar, with a number of options todefine the exact appearance.
This control is not commonly used in Writer. In
Calc, a Data tab appears on the Control
Properties dialog box, allowing you to link thescroll bar to a cell.
Behaves exactly like a push button, butdisplays as an image. Choose the image in theGraphics option on the General tab in theControl Properties dialog box.
Only useful when the form is connected to adata source and a field in the data source
exists that can hold images. You can add newimages to the database or retrieve and display
images from it.
Stores a date. You need to configure theearliest and latest dates the field will accept,
the default date, and the date format. You can
add a spinner.
Works like a date field but specifies a time.

Using Forms in WriterMore Controls toolbar
File Selection

Allows a user to select a file, either by typing
the path and name directly or by clicking on a
Browse button and choosing the file from a
dialog box.

Numeric Field

Displays a number. You need to specify
formatting, maximum, minimum and default
values. You can add a spinner.

Currency Field

Works like a numeric field; additionally you can
add a currency symbol.

Pattern Field

Group Box

Table Control

Navigation Bar

Form controls reference

Pattern fields are useful when the form links
into a data source. Specify an Edit Mask to
restrict what a user can enter into the field.
Specify a Literal Mask to restrict which data isdisplayed from the data source.
The group box control has two different uses
depending on whether wizards are on or off.
If wizards are on, creating a group box
launches the Group Element wizard. This
creates a group of options buttons (in which
only one may be selected at a time). In mostcases, using a group box is the best way tocreate a set of option buttons.
If wizards are off, a group box is simply a visual
box to group together different controls. It has
no effect on the way the controls operate.
Table Control is only useful with a data source.
If no data source is specified, you will beprompted to choose one in the Table Element
Wizard. You then pick the fields to display and,
when design mode is off, the data appears in
the table. The table also includes controls to
step through the records.
Records can be added, deleted, and modified in
the table.
A navigation bar is the same as the Form
Navigation toolbar (View > Toolbars > Form
Navigation), but can be placed anywhere in
the document and be resized.

11

Form Design toolbar
SelectSelects a form control to perform an action on
it.

Design mode on/off

Toggles between design mode on (to edit
forms) and design mode off (to use forms).

Control

Form

Form Navigator

Add Field

Activation Order

Open in Design Mode
Automatic Control
Focus

12

Launches form control properties dialog box.
This dialog box can be kept open as different
controls are selected.
Launches form properties dialog box,
controlling properties for the form as a whole,such as which data source it connects to.
The Form Navigator is a utility displaying all
the forms and controls in the current
document. It allows you to edit and deletethem easily.
If you use the Form Navigator, it's
recommended that you give your controls
names (in the properties dialog box). The nameappears in the navigator so, for example, if you
have ten text boxes, you can tell which iswhich.
Add Field is only useful if you have specified adata source for the form. If no data source is
specified, an empty box opens.
If you have specified a data source, Add Field
opens a list of all the fields in the specified
table, which you can then drag and drop onto
the page. The fields are placed on the page
with the name of the field before them.
This is a quick and easy way to create a form
from a data source.
Allows you to specify the order in which focus
shifts between controls. You can test the orderby leaving design mode and using Tab toswitch between the controls.
Opens the current form in design mode (to edit
the form rather than entering data into it).
If activated, focus is set to the first form
control.

Using Forms in WriterForm Design toolbar
Position and Size

Change Anchor

Alignment

Launches the Position and Size dialog box,
allowing you to specify both by typing inprecise values, rather than dragging thecontrol. You can also lock the size or position,
so they do not get changed accidentally. For
some controls, you can rotate and set the slant
and corner radius.
Just as with a frame, any form control can be
anchored to page, paragraph or character andalso anchored as a character (meaning that it
behaves like any other character on the page).
The Alignment button is disabled unless thecontrol is anchored as a character. You canalign a control in different ways, for example so
the top of the control lines up with the top of
the text or the bottom lines up with the bottomof the text.

Display Grid

Displays a grid of dots on the page, to help youline up controls.

Snap to Grid

When a control is brought close to a grid point
or line, it will snap to the grid. This makes it iseasier to line up controls.

Guides when Moving

When a control is being moved, lines extend
from the control horizontally and vertically tohelp you position it accurately.

Form controls reference

13

Example: a simple form
Create the document
Open a new document (File > New > Text Document). It is a goodidea to write down the outline of the document, without form controls,though of course it can easily be changed later.

Figure 3: Initial document without form controls

Add form controls
The next step is to add the form controls to the document. We will havefour controls:• Name is a text box• Sex is two option buttons, male or female.
• Favourite shape is a list of options.
• All shapes you like is a series of check boxes.
To add these controls:
1) Select View > Toolbars > Form Controls to open the Form
Control toolbar.
2) If the tools are not active, click the Design Mode On/Off
button to activate them.
3) Click the Text Box button, then click in the document and,with the left mouse button held down, drag the shape of theName text box to approximately the size you want.

14

Using Forms in Writer4) Make sure the Wizards On/Off button
border). Click the More Controls button
Controls toolbar.

is on (shaded with ato launch the More

5) On the More Controls toolbar, click the Group Box button.
Draw a group box by the Sex: entry. The Group Element Wizard
opens.
a) On the first page of the wizard, enter two names for the
options fields: Male and Female. Click the >> button after
each entry. Click Next >>.

Figure 4: Specifying names for option fieldsb) On the next page, select the option No, one particular field is
not going to be selected. Click Next>>.

Figure 5: Selecting a default field

Example: a simple form

15c) Give a value to your fields. Typically, you would give one field
the value 1 and the other field the value 2. If there are morethan 2 option fields, you would give them values of 3, 4, andso on. Click Next >>.

Figure 6: Assigning field valuesd) You can either delete the caption or give a caption to yourGroup Box. Then click Finish.

Figure 7: Create Caption Option6) Now create the list box. On the Form Controls toolbar, click the
Wizards On/Off button

to turn wizards off. Click the List Box

buttonand draw a list box by Favourite Shape: in the
document. This will just be an empty pane for now.

16

Using Forms in Writer

7) Finally create four check boxes by All the shapes you like. Clickon the Check Box button
and then draw out four checkboxes, side by side across the page.
You should now have a document looking something like Figure 8.

Figure 8: Document with form controls

Configure form controls
No further configuration is required to the Name and Sex fields, but
you could, if you wish, give a name to each control and change theappearance of the controls.
The list box must be configured to add the list of options. The checkboxes must be configured to add in the names (instead of Check Box,
Check Box1, and so forth). Following are instructions to configure
these controls:
1) Be sure design mode is on. Double-click on the List Box control
within the document to open the control’s Properties dialog box.
Select the General tab.
2) In the List Entries box (scroll down if it is not visible), type thenames of the shapes (Circle, Triangle, Square, Pentagon)
separated by ”;” and then press Enter. You should end up with aline saying “Circle”;”Triangle”;”Square”;”Pentagon”.

Example: a simple form

17

Figure 9: Properties dialog box for a list box3) Click on the first Check Box. The Properties dialog box stays open
but changes to show the properties for the check box.

Figure 10: Top part of Properties dialog box for acheck box
4) Change the Label fieldfrom Check Box to Circle and press Enter.
The cursor moves to Label Field and the label on the check box
in the document changes immediately.

18

Using Forms in Writer5) Click on each of the other three check boxes in turn. Change theLabel in the Properties dialog box to Triangle, Square, andPentagon in turn.
6) Close the Properties dialog box.
7) Turn design mode off

and close the two Controls toolbars.

You have now completed the form, which should look something like
Figure 11.

Figure 11: Completed form

Finishing touches
The form is complete, but you are free to make further changes to the
document. If you were sending this out to other people to complete,
you would probably want to make the document read-only. The effectwould be that users would be able to fill in the form but not to makeany other changes to the document.
To make the document read-only, select Tools > Options >OpenOffice.org > Security > Open this document in read-only
mode.
Note

If the document is read-only, anyone filling in the form willneed to use File > Save as to save the document.

Example: a simple form

19

Accessing data sources
The most common use for a form is as the front end of a database. You
can provide a form that allows users to enter information into a
contacts database and, because it is part of a Writer document, theform can contain graphics, formatting, tables, and other elements tomake it look just the way you want. Modifying the form is as simple asediting a document.
OpenOffice.org can access numerous data sources. These include
ODBC, MySQL, Oracle JDBC, spreadsheets and text files. As a generalrule, databases can be accessed for read and write; other data sources(such as spreadsheets) are read-only.

Tip

To see the list of supported data source types for youroperating system, choose File > New > Database. On the firstpage of the Database Wizard (Figure 12), select Connect to an
existing database and then open the drop-down list. An
example is shown in Figure 15.

Creating a database
Chapter 8 (Getting Started with Base) in the Getting Started guidecovers in more detail how to create a database. Here we give a shortguide to creating a very simple database with OOo Base.
1) Select File > New > Database to start the Database Wizard(Figure 12).
2) Select Create a new database and click Next.
3) On the next page, select Yes, register the database for me andOpen the database for editing. Registering the database justmeans that it can be accessed from other OOo components suchas Writer and Calc. You need to do this if you want to link yourforms into it.
4) Click Finish and save your new database, giving it a name.
Unlike creating other documents in OOo, databases must be
saved when you first create them.

20

Using Forms in WriterFigure 12: Database Wizard
After saving the database, you should see the main Base window(Figure 13), which contains three panels. The left-hand panel is
Database, with icons for Tables, Queries, Forms and Reports.

Figure 13: Main Base window

Accessing data sources

21

The next step is to create a table. Again, this is covered in more detailin Chapter 8 (Getting Started with Base) in the Getting Started guide.
Here we are going to create a small table as an example.
1) Choose Tables in the left-hand column, then choose Create
Table in Design View under Tasks.
2) Use the Table Design window to tell Base which fields to create.
We will have just three fields: Name, Address, and Telephone.

Figure 14: Database table design3) On the first line, enter under Field Name ID and set the Field
Type to Integer [INTEGER]. In the gray box at the left of the line,
right-click and select Primary Key, bringing up a key icon in thebox. In the Field Properties at the bottom of the window is an
Auto Value option; change this to Yes.

Tip

Setting up the Primary Key field with Auto Value set to Yes is
an important step. If this is not done, the form you create later
will be much trickier to use and may generate errors for theuser. Make sure you get this step right!

4) On three lines, enter under Field Name Name, Address andTelephone. Accept the default Field Type of Text [VARCHAR] andleave Description blank.
5) Save the table (File > Save). You will be prompted to name it.
The name can be anything you like.
6) Finally, save the whole database from the main Base window(File > Save).
22

Using Forms in WriterAccessing an existing data source
If you have an existing data source, such as a spreadsheet or database,
you simply need to tell OpenOffice.org about it. This is called
registering a data source.
To register an existing data source:1) Select File > New > Database to launch the Database Wizard.
2) Select Connect to an existing database and choose the typefrom the drop-down list.

Figure 15: Using the Database Wizard to connect to an
existing database3) Click Next and follow the instructions to select the database toregister (the exact process varies between different types of data
source).
4) In Step 3: Save and proceed, check that Yes, register the
database for me is selected. Deselect Open the database forediting – you just need to register it, not edit it through Base.

Accessing data sources

23

Creating a form for data entry
Whether you created a new database, or already had a data source, it
must be registered with OpenOffice.org (see above). Once it isregistered, linking your form to the data source is simple. Follow thesesteps to create a new form and link it to a registered data source.
1) Create a new document in Writer (File > New > Text
Document).
2) Design your form, without putting in the actual fields (you canalways change it later).
3) Show the Form Controls toolbar (View > Toolbars > Form
Controls).
4) Click the Design Mode On/Off button
to put the document
into design mode, if necessary. With design mode off, most of thetoolbar buttons are grayed out. If the Design Mode button is also
grayed out, click on the Select button to activate it.
5) Click the Text Box button. Click in the document and, holding
down the left mouse button, drag the mouse to create a text box
for the first form field (for example, Name, if you are linking to
the database created above).
6) Click the Text Box button
again and drag the mouse to draw
another field. Additional fields, of any type, can be added in thesame way (click and drag).
So far you have followed the same steps you used before when you
created your first form. Now you link your form with the data source
you registered.
1) Click the Form buttonin the Form Controls toolbar, or rightclick on any of the fields you inserted and select Form, to open
the Form Properties dialog box.
2) In the Form Properties dialog box, click on the Data tab.
•
Set Data Source to be the data source you registered.
•
Set Content Type to be Table.
•
Set Content to be the name of the table you want to access.
•
Close the dialog box.

24

Using Forms in WriterFigure 16: Form properties, connecting
to a data source3) For each form control in turn, launch the Properties dialog box..
Click on the control to select it (so small green boxes appear
around it). Then either right-click and select Control or click on
the Control buttonon the Form Controls toolbar.
4) In the Properties dialog box, click on the Data tab (Figure 17). If
you set up the form correctly, the Data Field option will contain alist of the different fields in the data source (for example, Name,
Address and Telephone). Select the field you want.

Figure 17: Form control properties,
Data tab5) Repeat for each control in turn until every control that should be
has been assigned to a field.

Accessing data sources

25

Tip

If you created a database in OOo Base and your Primary Key
field had Auto Value set to Yes, that field does not need to bepart of the form. If Auto Value was set to No, you will have toinclude it and have your users enter a unique value into thatfield whenever they make a new entry—not something that isrecommended.

Entering data into a form
Once you have created a form and tied it to a database, you want to
use it to enter data into your data source, or modify data already there.
1) Make sure that the form is not in design mode. In the Form
Controls toolbar, click on the Design Mode On/Off button.
If design mode is off, most of the buttons on the toolbar will begrayed out.
2) Make sure that the Form Navigation toolbar is on (View >Toolbars > Form Navigation). This toolbar normally appears at
the bottom of the window.

Figure 18: Form Navigation toolbar
3) If there is existing data in the data source, use the control buttons
on the Form Navigation toolbar to look at different records. You
can amend data in a record by editing the values in the form. To
submit the changes, press the Enter key with the cursor in thelast field. The record is saved and the next record is displayed.
4) If there is no data in the form, you can start entering information
by typing into the fields of the form. To submit the new record,press the Enter key with the cursor in the last field.
5) Other functions can be performed from the Form Navigation
toolbar, including deleting a record and adding a new record.

26

Using Forms in Writer

Advanced form customization
Linking a macro to a form control
You can set any form control (for example, text box or button) toperform an action when triggered by some event. To see the full list of
events, right-click on the form control when the design mode is on,
select Control and click on the Events tab.

Figure 19: Control properties, Events tab
To assign a macro to an event:1) Create the macro. See Chapter 13 (Getting Started with Macros)in the Getting Started guide.
2) Be sure the form is in design mode. Right-click on the form
control, select Control and click on the Events tab.
3) Click the browse
button to bring up the Assign action dialog
box (Figure 20).
4) Click the Macro button and select the macro from the list in the
Macro Selector dialog box. You return to the Assign action dialog
box. Repeat as needed, then click OK to close the dialog box.

Advanced form customization

27

Figure 20: Assign action dialog box
Macros can also be assigned to events relating to the form as a whole.
To assign these, right-click on a form control in the document, selectForm and click on the Events tab.

Read-only documents
Having created your form, you want whoever is using it to be able toaccess the information stored in the database, or complete the form,
without changing the layout. To do this, make the document read-onlyby selecting Tools > Options > OpenOffice.org > Security> Open
this document in read only mode.

Fine-tuning database access permissions
By default, when a database is accessed from a form, any changes canbe made to it: records can be added, deleted, and amended. You may
not want that behavior. For example, you may want users to be able
only to add new records or to be prohibited from deleting existing
records.
In design mode, right-click on a form control and select Form from the
pop-up menu. On the Data tab of the Form Properties dialog box are anumber of options: Allow additions, Allow deletions, Allow
modifications and Add data only. Set each of these to Yes or No tocontrol the access users have to the data source.
28

Using Forms in WriterFigure 21: Data Properties of a Form
Individual fields can also be protected. This might be useful if you
wanted a user to be able to modify some parts of a record but only
view others, such as a stock list where item descriptions are fixed andquantities can be modified.
To make an individual field read-only, in design mode, right-click on theform control within the document and select Control from the pop-up
menu. Select the General tab and set Read-only to Yes.

Form control formatting options
You can customize the way form controls look and behave in a numberof ways. These are all accessed in design mode. Right-click on the form
control, select Control from the pop-up menu and select the Generaltab in the Properties dialog box.
• Set a label for the control in the Label box (not to be confusedwith the box called Label Field). Some form controls, such aspush buttons and option buttons, have visible labels that can be
set. Others, such as text boxes, do not.
• Set whether the form control will print out if the document isprinted with the Print option.
• Use the Font setting to set the font, typeface, and size for a field’slabel or for text typed into a field. This setting does not effect thesize of check boxes or option buttons.
Advanced form customization29

• For a text box, you can set the maximum text length. This is very

•

•

•
•

useful when adding records into a database. Every database text
field has a maximum length and, if the data entered is too long,
OOo displays an error message. By setting the maximum text
length of the form control to be the same as that of the databasefield, this error can be avoided.
You can set the default option for a form control. By default, acontrol is blank, or has every option unselected. You can set thecontrol to start with a particular option or list item selected.
For controls where a password is being entered, setting the
Password character (for example to *) displays only thatcharacter, but saves what the user really types.
You can add additional information and help text for a form
control.
Other formatting controls such as background color, 3-D look, text
formatting, scroll bars, and borders allow you to further define
how the control appears.

XFormsXForms are a new type of web form, developed by the World Wide Web
Consortium (W3C). OpenOffice.org 3 supports the XForms 1.0 open
standard for creating web forms with XML.
In OpenOffice.org, an XForms document is a special type of Writer
document. XForms use the same controls as the ordinary forms
described in this chapter.
After you create and save an XForms document, you can open the
document, fill out the form, and submit the changes to a server.
A detailed discussion of XForms is beyond the scope of this chapter, as
it is related more to databases than word processing. A good tutorial
introduction is J. David Eisenberg’s XForms and OpenDocument in
OpenOffice.org, available fromhttp://opendocument.xml.org/files/xforms_ooo_06_10_25.pdf andhttp://books.evc-cit.info/xforms_ooo_06_08_15.odt. Another good
resource is Valden Longhurst’s Using XForms and the OpenDocument
format in OpenOffice.org and StarOffice,http://wiki.services.openoffice.org/wiki/Documentation/Using_XForms

30

Using Forms in Writer