Getting Started With Forms

Quick terminology note

In the following procedures, we'll use the term control . A control is an object on a form that connects with some field in a table or query, allowing you to enter data for that field through the form. Examples of controls are text boxes, drop-down lists, and check boxes. By default, the forms you create with AutoPilot will contain mostly labels and text boxes. The labels tell you the name of the field, and the text boxes let you enter data in the field.

Introduction to Forms

Forms let you create a graphical environment for working with your data sources. You can create forms that show all fields in a data source, or you can create forms that show only specific fields. For example, you could create a form that lets you view and modify only name and email address information for your contacts, or use a query to create a form for only certain records.

graphics/36inf01.jpg

You can create a form for a query. Since a query is only a part of a table, a form for a query really just supports the table. Creating a form for a query lets you work on smaller groupings of fields.

Using Forms to View Data

Note

For more information, see Using Forms to View Data on page 950.


Once your form is put together, via the AutoPilot or your own efforts, your users can run through the form in a number of ways. See Figure 36-1.

  • Just clicking through the records in order, using the icons at the bottom of any form, AutoPilot-created or from scratch.

  • Using the sort icons, also available, to see data in a particular order

  • Using the search feature

  • Using filters to narrow down the data to, for instance, everyone in the customer database who's complained bitterly about the Enterprise JavaBeans course.

Figure 36-1. Example of how to find data in a form

graphics/36fig01.jpg

Note

You can download an example data source and form that connects to it at www.getopenoffice.org/templates.html


Using Forms for Data Entry (Writin', Insertin', and Deletin')

If your data source is up to it and if you think it's a good decision for your security situation, then you can very easily use forms for data entry.

  • Change existing data

  • Delete existing records

  • Add new records

Note

OpenOffice.org cannot edit Oracle databases. This is a known problem, so check the sun.com/staroffice site periodically to see if they've come up with a patch.


First note

It helps if you have the following skills too, but that's just for adding more powerful processing:

  • Do anything with SQL (are you the MacGyver of SQL?)

  • Learn to write macros

Second note
graphics/triangle.gif

This depends on your database, of course. Is your security set up so people can just edit it from forms? That might not always be wise. Likewise, data sources based on text files and spreadsheets aren't editable. Though you can save either form as .DBF and then you've got an editable data source.

Third note

The form setup and how it interacts with data sources is weird once in a while. It's not wildly inconsistent but it does help if you kill an occasional chicken.

That said, Figure 36-2 shows how you'd add a record to a data source, as well as the tools to use for deleting. (Except, as noted, with AutoPilot forms which are rigidly read-only.)

Figure 36-2. Go to the end of the table and type the data

graphics/36fig02.jpg

With the new empty row available, type the data, then click Save Record.

graphics/36inf02.jpg

In the data source viewer window, you can click Refresh to make the change show up

Figure 36-3 shows the resulting change to the data source.

Figure 36-3. See the results in the data source

graphics/36fig03.jpg

Making a Basic Data Entry Form

For instance, if you want to create a basic form where you can read and edit a dBase data source full of your business contacts, you could do that easily. Make a new HTML or Writer document, get the Forms tearoff menu up, drag the fields onto the form (more on that later), and you're good to go. The change to any field is made as soon as the focus leaves the field.

An example is shown in Figure 36-4.

Figure 36-4. A simple data editing form for a dBase database

graphics/36fig04.jpg

The Kinds of Controls (Labels, Buttons, Fields, Etc.) You Can Have in a Form

You can also add text and graphics to a form, making it a more pleasant and user -friendly tool for working with your data.

To see all the controls available, click and hold down the Form icon on the toolbar, as shown in Figure 36-5. Hold the mouse pointer over each one to see the name; not all controls are available all the time.

Figure 36-5. The Form tearoff menu

graphics/36fig05.jpg

Figure 36-6 shows examples of some of the fields.

Figure 36-6. Form controls

graphics/36fig06.jpg

Getting in Deeper With SQL, Macros, and Events

To add records or do any processing, you need to take a deep breath and do some SQL, macros, or both. Right click any control and choose Form or Control, and take a look at the options on the Data and Events tabs. See an example in Figure 36-7.

Figure 36-7. Adding macros and SQL to a control

graphics/36fig07.jpg

You can associate SQL programming with the data, and macros with events. Events (shown at right) are things that users do like clicking, going from one field to another, etc. So you can do macro X when a user completes event Y, liking running the OpenFile macro when the Click Button event happens.

There are a bunch of existing macros (see Figure 36-8), and the help provides a description of each one. You can get the whole macro API from www.openoffice.org. See also Macro Basics on page 961.

Figure 36-8. Example of a form created using AutoPilot

graphics/36fig08.jpg

graphics/36inf03.jpg

Since going into how to use a couple new programming languages isn't something our editor is going to allow us time for, you won't find extensive guidance on how to create great data entry forms in this book. However, we do cover how to add controls to forms, and the Help has a lot of great information on macros. In addition, you're likely to get a lot of help from the great resources and mailing lists at www.openoffice.org.



OpenOffice. org 1.0 Resource Kit
OpenOffice.Org 1.0 Resource Kit
ISBN: 0131407457
EAN: 2147483647
Year: 2005
Pages: 407

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net