Difference between revisions of "Documentation/OOoAuthors User Manual/Getting Started/Getting Started with Base"

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 2: Line 2:
 
This page was created by converting ODT to Mediawiki using Writer2MediaWiki.
 
This page was created by converting ODT to Mediawiki using Writer2MediaWiki.
  
This is the first page of Chapter '''10''' of '''Getting Started with OpenOffice.org 2.x''' (Third edition), produced by the [http://oooauthors.org/ OOoAuthors group]. A PDF of this chapter is available from the [http://documentation.openoffice.org/manuals/oooauthors2/ OOoAuthors Guides page] at OpenOffice.org.
+
This is the first part of Chapter '''10''' of '''Getting Started with OpenOffice.org 2.x''' (Third edition), produced by the [http://oooauthors.org/ OOoAuthors group]. A PDF of this chapter is available from the [http://documentation.openoffice.org/manuals/oooauthors2/ OOoAuthors Guides page] at OpenOffice.org.
  
 
This chapter is continued here:
 
This chapter is continued here:
Line 382: Line 382:
  
 
XXXXXXXXXXX
 
XXXXXXXXXXX
 
'''Accessing other data sources'''
 
----
 
:OpenOffice.org allows data sources to be accessed and then linked into OOo documents. For example, a mail merge links an external document containing a list of names and addresses into a letter, with one copy of the letter being generated for each entry.
 
 
:To register a data source, choose '''File > New > Database''' to open the ''Database Wizard''. Select '''Connect to an existing database'''. This allows access to the list of data sources that can be registered with OOo. These data sources can be accessed similarly to a dBase database as explained in the next section.
 
 
:Once a data source has been registered, it can be used in any other OOo component (for example Writer or Calc) by selecting '''View > Data Sources''' or pressing the ''F4 ''key.
 
 
{|
 
| ||  '''Tip'''  ||Mozilla Address Books and dBase databases (among others) can be accessed, and entries can be added or changed.||
 
|-
 
|}
 
 
{|
 
| ||  '''Caution '''<br/> inline:graphics1.png  ||Spreadsheets can be accessed, but no changes can be made in the spreadsheet entries. All changes in a spreadsheet sheet must be made in the spreadsheet, itself. Update the database afterwards to see the changes made in the spreadsheet.||
 
|-
 
|}
 
 
:'''Accessing a ''''''dBase database''''''dBase database''''''dBase database'''
 
 
## '''File ''''''>'''''' New ''''''>'''''' Database ''' opens the ''Database Wizard'' window.
 
{|
 
| ||  '''Note'''  ||Clicking the ''New'' icon and ''Database'' in the drop-down menu also open the ''Database Wizard'' window. (See Figure 1.)||
 
|-
 
|}
 
 
## Select '''Connect to an existing database'''. Pressing the ''TAB'' key highlights the ''Database type'' drop-down list. Typing ''D'''' ''selects ''dBase. ''Click'' '''''Next.'''
 
{|
 
| ||  '''Note'''  ||Clicking the arrows opens a menu from which you can select ''dBase ''(Figure 58'').''||
 
|-
 
|}
 
 
: inline:Frame15.png
 
 
## Click ''Browse'' and select the folder containing the database. Click '''Next'''.
 
## Accept the default settings: ''Register the database for me, ''and'' Open the database for editing''. Click''' Finish'''. Name and save the database in the location of your choice.
 
## Create the ''Form'' using the ''Form Wizard'' as explained in “Creating a database form" beginning on page 14.
 
:'''Accessing a ''''''Mozilla address book''''''Mozilla address book'''
 
 
:Accessing a Mozilla Address Book is very similar to accessing a dBase database.
 
 
## Select '''File > New > '''Database.
 
## Select ''Connect to an existing database''. Select ''Mozilla Address Book'' as the database type (Figure 58).
 
## Register this data source.
 
:These are steps 1, 2 and 4 of “Accessing a dBase database" on page 33.
 
 
:'''Accessing ''''''spreadsheets'''
 
 
:Accessing a spreadsheet is also very similar to accessing a dBase database.
 
 
## Select '''File ''''''>'''''' New ''''''>'''''' Database'''.
 
## Select ''Connect to an existing database''. Select ''Spreadsheet'' as the ''Database type'' (Figure 58).
 
## Click '''Browse''' to locate the spreadsheet you want to access. If the spreadsheet is password protected, check the ''Password required'' box. Click '''Next'''.
 
## If the spreadsheet requires a user's name, enter it. If a password is also required, check its box. Click '''Next'''.
 
{|
 
| ||  '''Caution '''<br/> inline:graphics56.png  ||This method of accessing a spreadsheet does not allow you to change anything in the spreadsheet. All modifications must be made in the spreadsheet itself. This method only allows you to view the contents  of the spreadsheet, run queries, and create reports based upon the data already entered into the spreadsheet.||
 
|-
 
|}
 
 
:'''Registering databases created by OOo2.x'''
 
 
:This is a simple procedure. '''Tools > Options > OpenOffice.org Base > Databases.''' Under ''Registered databases,''there is a list of these databases. Below this list are three buttons: '''New...,''' '''Delete,''' '''Edit... '''To register a database created by OOo2.x:
 
 
## Click '''New.'''
 
## '''Browse''' to where the database is located.
 
## Make sure the registered name is correct.
 
## Click '''OK.'''
 
'''Using data sources in OpenOffice.org'''
 
----
 
:Having registered the data source, whether a spreadsheet, text document, external database or other accepted data source, you can use it in other OpenOffice.org components including Writer and Calc.
 
 
:'''Viewing data sources'''
 
 
:Open a document in Writer or Calc. To view the data sources available, press ''F4'' or select '''View ''''''>'''''' Data Sources''' from the pull-down menu. This brings up a list of registered databases, which will include Bibliography and any other database registered.
 
 
:To view each database, click on the '''+ '''to the left of the database's name. (This has been done for the Automobile database in Figure 59.) This brings up Tables and Queries. Click on the '''+''''' ''next to Tables to view the individual tables created. Now double-click on a table to see all the records held in it.
 
 
: inline:Frame29.png
 
 
:'''Editing data sources'''
 
 
:Some data sources can be edited in the View Data Sources dialog. A spreadsheet can not. A record can be edited, added or deleted.
 
 
:The data is displayed on the right side of the screen. Click in a field to edit the value.
 
 
:Beneath the records are five tiny buttons. The first four move backwards or forwards through the records, or to the beginning or end. The fifth button, with a small star, inserts a new record (Figure 60).
 
 
: inline:Frame3.png
 
 
:To delete a record, right-click on the gray box to the left of a row to highlight the entire row, and select '''Delete Rows''' to remove the selected row.
 
 
: inline:Frame69.png
 
 
:'''Launching Base to work on data sources'''
 
 
:You can launch OOo Base at any time from the View Data Source pane. Just right-click on a database or the Tables or Queries icons and select '''Edit Database File'''. Once in Base, you can edit, add and delete tables, queries, forms and reports.
 
 
:'''Using data sources in OOo documents'''
 
 
:To insert a field from a table into a document (for example a Calc spreadsheet or Writer document), click on the field name (the gray square at the top of the field list) and, with the left mouse button held down, drag the field onto the document. In a Writer document, it will appear as <FIELD> (where FIELD is the name of the field you dragged). In Calc it will appear as a text box.
 
 
:One common way to use a data source is to perform a mail merge. Selecting '''Tools > Mail Merge Wizard''' or clicking on the Mail Merge icon (a small paper-and-envelope icon on the View Data Source pane) launches the Mail Merge wizard which steps through creating a mail merge document. This is covered in Chapter 11 (Using Mail Merge) in the ''Writer Guide''.
 
 
'''Entering data in a form'''
 
----
 
:''Records'' are used to organize the data we enter into a form. They also organize the data we enter into a subform (Figure 62).
 
 
: inline:Frame17.png
 
 
:Each type of field allows a different method to enter the data. In most if not all cases, more than one method can be used.
 
 
:The first step to entering data in a form is to open it from the main database window.
 
 
** Click the Forms icon in the ''Database'' list.
 
** Find the form's name in the ''Forms'' list (Vacations).
 
** Double-click the form's name.
 
:The quickest way to enter a date in the Date field is to click the arrow that opens the dropdown calendar. Then click the date you want (Figure 63). Use the ''Tab'' key to go to the Odometer field.
 
 
** Click the left arrow before May to go back one month (April 2007).
 
** Click the right arrow after 2007 to go forward one month (June 2007).
 
** Multiple clicks in either direction will change the month and year the same number of times as the number of clicks.
 
: inline:Frame70.png
 
 
:The Odometer, Tolls, and Motel fields are numerical fields. Enter values directly into them, or use the ''up'' and ''down arrows''. When the value is entered, use the ''Tab'' key to go to the next field.
 
 
** The ''up arrow'' increases the value, and the ''down arrow'' decreases the value.
 
** These two arrows only change the numerals to the left of the decimal place.
 
** Numerals to the right of the decimal place must be changed by deleting them and typing the desired ones.
 
:The Motel's Payment field is a dropdown list. If as in my case, all of the elements of the list start with different letters, typing the first letter will select the desired letter.
 
 
** If two or more elements of the list have the same first letter, repeated typing of the first letter will cycle through the elements with this same first letter. So, if you accidentally go past the the element you wanted, you can keep typing the first letter until it reappears again.
 
** When the selection is correct, use the ''Tab'' key to go to the Misc. field.
 
:The rest of the fields of the main form are either numerical fields or dropdown lists until we reach the Misc. Notes field. It is a text field. Type anything you desire in this field just as you would any simple text editor.
 
 
{|
 
| ||  '''Caution '''<br/> inline:graphics64.png  ||Since the ''Tab'' key is used to move between fields, it can not be used in a text field. All spacing must be done by the ''spacebar''. Finally, the'' Enter'' key only acts as a line break to move the cursor to the next line.||
 
|-
 
|}
 
 
{|
 
| ||  '''Note'''  ||If we did not have a subform for fuel data, using the ''Tab'' key would save all of the fields, clear them, and make the form ready to accept data on the second record.||
 
|-
 
|}
 
 
:Since we have a subform form, using the ''Tab'' key places the cursor in the first Date field of the subform with the date automatically entered to match the Date field of the main form.
 
 
:The FuelCost, FuelQuanity, and Odometer fields are numerical fields. The Payment field is a dropdown list. Enter the data just as you did in the main form, and use the ''Tab'' key to go to the next field.
 
 
:When you use the ''Tab'' key to leave the Payment field, it goes to the Date field of the next line and automatically enters the date. Now you can enter your second set of fuel data for this day.
 
 
:To move to another record when the form has a subform, the directional arrows at the bottom must be use. There are four of them from left to right: ''First Record, Previous Record, Next Record'', and ''Last Record'' (Figure 64). To the right of these arrows in the ''New Record'' icon.
 
 
:To create a new record while in another record, click the ''New Record'' icon. And, two choices exist for creating a new record following the present record.
 
 
** Click the ''Next Record'' icon.
 
** Or, click the ''New Record'' icon.
 
: inline:Frame75.png
 
 
{|
 
| ||  '''Tip'''  ||The number in the Record box is the number of the record whose data is shown in the form. (The data from the second record of the Vacations form was displayed when I took the screenshot for Figure 64.) <br/>If you know the number of the record you want, you can enter it into the record box and then use the ''Enter'' key to take you to that record.||
 
|-
 
|}
 
 
:Figure 65 is a record with data inserted in its fields. Note that not all fields have data in them. It is only necessary to have data in every field if you determine ahead of time to require all fields contain data.
 
 
: inline:Frame76.png
 
  
 
'''Creating queries''''''Creating queries'''
 
'''Creating queries''''''Creating queries'''

Revision as of 21:39, 19 June 2007

Template:NeedsWork This page was created by converting ODT to Mediawiki using Writer2MediaWiki.

This is the first part of Chapter 10 of Getting Started with OpenOffice.org 2.x (Third edition), produced by the OOoAuthors group. A PDF of this chapter is available from the OOoAuthors Guides page at OpenOffice.org.

This chapter is continued here:

<< User Manuals page
<< Getting Started Table of Contents
<< Chapter 9 Getting Started with Impress   |   Chapter 11 Getting Started with Math >>


Introduction

A data source, or database, is a collection of pieces of information that can be accessed or managed by OpenOffice.org (OOo). For example, a list of names and addresses is a data source that could be used for producing a mail merge letter. A shop stock list could be a data source managed through OOo.

Note OpenOffice.org uses the terms “Data Source" and “Database" to refer to the same thing, which could be a database such as MySQL or dBase or a spreadsheet or text document holding data.

This chapter covers creating a database, showing what is contained in a database and how the different parts are used by OOo. It also covers using the Base component of OOo to register other data sources. A data source can be a database, spreadsheet, or text document.

Data sources are only introduced in this chapter. For more detailed information about the use of databases, see the Database Guide.

Note OOo Base uses the HSQL database engine. All of the files created by this engine are kept in one zipped file. The database forms are included in this zipped file.

A database consists of a number of fields that contain the the individual pieces of data. Each table of the database is a group of fields. When creating a table, you also determine the characteristics of each field in the table. Forms are for data entry into the fields of one or more tables associated with the form. They can also be used for viewing fields from one or more tables associated with the form. A query creates a new table from the existing tables based upon how you create the query. A report organizes the information of the fields of a query in a document according to your requirements.

Caution
inline:graphics104.png
The database in OOo requires Java Runtime Environment (JRE). If you do not have it on your computer, you can download it from www.java.com and install it following the instructions on the site. It should be Java 5.0 or higher. In OOo, use Tools > Options > OpenOffice.org > Java to register Java.
Window's version of JRE can not be used, while there are other versions that can.

Base creates relational databases. This makes it fairly easy to create a database in which the fields of the database have relationships with each other.

For example: Consider a database for a library. It will contain a field for the names of the authors and another field for the names of the books. There is an obvious relationship between the authors and the books they have written. The library may contain more than one book by the same author. This is what is known as a one-to-many relationship: one author and more than one book. Most if not all the relationships in such a database are one-to-many relationships.

Consider an employment database for the same library. One of the fields contains the names of the employees while others contain the social security numbers, and other personal data. The relationship between the names and social security is one-to-one: only one social security number for each name.

If you are acquainted with mathematical sets, a relational database can easily be explained in terms of sets: elements, subsets, unions, and intersections. The fields of a database are the elements. The tables are subsets. Relationships are defined in terms of unions and intersections of the subsets (tables).

To explain how to use a database, we will create one for automobile expenses. In the process, we will be explaining how a database work.

Creating a database

The first step in creating a database is to ask yourself many questions. Write them down, and leave some space between the questions to later write the answers. At least some of the answers should seem obvious after you take some time to think.

You may have to go through this process a few times before everything becomes clear in your mind and on paper. Using a text document for these questions and answers makes it easier to move the questions around, add additional questions, or change the answers.

Here are some of the questions and answers I developed before I created a database for automobile expenses. I had an idea of what I wanted before I started, but as I began asking questions and listing the answers, I discovered that I needed additional tables and fields.

What are the fields going to be? My expenses divided into three broad areas: fuel purchases, maintenance, and vacations. The annual cost for the car's license plate and driver's license every four years did not fit into any of these. It will be a table of its own: license fees.

What fields fit the fuel purchases area? Date purchased, odometer reading, fuel cost, fuel quantity, and payment method fit. (Fuel economy can be calculated with a query.)

What fields fit the maintenance area? Date of service, odometer reading, type of service, cost of service, and next scheduled service of this type (for example, for oil changes list when the next oil change should be). But it would be nice if there was a way to write notes. So, a field for notes was added to the list.

What fields fit the vacations area? Date, odometer reading, fuel (including all the fields of the fuel table), food (including meals and snacks), motel, total tolls, and miscellaneous. Since these purchases are made by one of two bank cards or with cash, I want a field to state which payment type was used for each item.

What fields fit into the food category? Breakfast, lunch, supper, and snacks seem to fit. Do I list all the snacks individually or list the total cost for snacks for the day? I chose to divide snacks into two fields: number of snacks and total cost of snacks. I also need a payment type for each of these: breakfast, lunch, supper, and total cost of snacks.

What are the fields that are common to more than one area? Date appears in all of the areas as does odometer reading and payment type.

How will I use this information about these three fields? While on vacation, I want the expenses for each day to be listed together. The date fields suggest a relationship between the vacation table and the dates in each of these tables: fuel and food, This means that the date fields in these tables will be linked as we create the database.

The type of payment includes two bank cards and cash. So, we will create a table with a field for the type of payment and use it in list boxes in the forms.

Tip While we have listed fields we will create in the tables of the database, there is one more field that may be needed in a table: the field for the primary key. In some tables, the field for the primary key has already been listed. In other tables such as the payment type, an additional field for the primary key must be created.

Creating a new database

inline:Frame1.png

To create a new database, click the arrow next to the New icon. In the drop-down menu, select Database (Figure 1). This opens the Database Wizard. You can also open the Database Wizard using File > New > Database.

The first step of the Database Wizard has one question with two choices: Create a new database or Connect to an existing database. For this example, select Create a new database and then click Next.

The second step has two questions with two choices each. The default choice for the first question is Yes, register the database for me and the default choice for the second question is Open the database for editing. Make sure these choices are selected and click Finish.

Note If the database is not registered, it will not be accessible to the other OOo components such as Writer and Calc. If the database is registered, other components can access it.

Save the new database with the name Automobile. This opens the Automobile - OpenOffice.org Base window. Figure 2 shows part of this window.

Tip Every time the Automobile' database is opened, the Automobile - OpenOffice.org Base window opens. Changes can then be made to the database. The title for this window is always (database name) - OpenOffice.org.
Caution
inline:graphics67.png
As you create a database, you should save your work regularly. This means more than just saving what you have just created. You must save the whole database as well.
For example, when you create your first table, you must save it before you can close it. If you look at the Save icon in the Standard toolbar at the top after closing the table, it will be active. Click the Save icon, and this icon will be grayed out again. Not only the table has been saved, but it also been made a part of the database.

Creating database tables

Note In a database, a table stores information for a group of things we call fields. For example, a table might hold an address book, a stock list, a phone book or a price list. A database can have from one to several tables.

To work with tables, click the Tables icon in the Database list, or use Alt+a. The three tasks that you can perform on a table are in the Task list (see Figure 2).

inline:Frame2.png

Using the Wizard to create a table

Caution
inline:graphics103.png
Every table requires a Primary key field. (What this field does will be explained later.) We will use this field to number our entries and want that number to automatically increase as we add each entry.

Since none of the fields we need for our Automobile database are contained in any of the wizard tables, we will create a simple table using the wizard that has nothing to do with our database. This section is an exercise in explaining how the Wizard works.

The Wizard permits the fields of the table to come from more than one suggested table. We will create a table with fields from three different suggested tables in the Wizard.

Click Use Wizard to Create Table. This opens the Table Wizard.

Note A field in a table is one bit of information. For example, in a price list table, there might be one field for item name, one for the description and a third for the price. More fields may be added as needed.

Step 1: Select fields.

You have a choice of two categories of suggested tables: Business and Personal. Each category contains its own suggested tables from which to choose. Each table has a list of available fields. We will use the CD-Collection Sample table in the Personal category to select the fields we need.

  1. Category: Select Personal. The Sample Tables drop down list changes to a list of personal sample tables.
  2. Sample Tables: Select CD-Collection. The Available fields window changes to a list of available fields for this table.
  3. Selected Fields: Using the > button, move these fields from the Available fields window to the Selected fields window in this order: CollectionID, AlbumTitle, Artist, DatePurchased, Format, Notes, and NumberofTracks.
  4. Selected Fields from another sample table. Click Business as the Category. Select Employees from the dropdown list of sample tables. Use the > button to move the Photo field from the Available fields window to the Selected fields window. It will be at the bottom of the list directly below the NumberofTracks field.
  5. If a mistake is made in the order as listed above, click on the field name that is in the wrong order to highlight it. Use the Up or Down arrow on the right side of the Selected Fields list (see Figure 3) to move the field name to the correct position. Click Next.
inline:Frame11.png
Caution
inline:graphics102.png
Below the Selected Fields list are two buttons: one with a +, and one with a -. These buttons are used to add or to remove fields from the Selected Fields list. Be careful when using these buttons until well acquainted with how to create tables (Figure 3).

Step 2: Set field types and formats.

In this step you give the fields their properties. When you click a field, the information on the right changes. You can then make changes to meet your needs. (See Figure 4.) Click each field, one at a time, and make the changes listed below.

inline:Frame4.png
Note If any of these fields requires an entry, set Entry required to Yes. If Entry required is set to Yes, this field must have something in it. For example if FirstName has Entry required set to Yes, having an entry with the first name missing will not be allowed. In general, only set Entry required to Yes if something must always be put in that field. By default, Entry required is set to No.
  • CollectionID: Change AutoValue from No to Yes.
  • AlbumTitle:
  • Entry required: If all of your music is in albums, change Entry required to Yes. Otherwise, leave Entry required as No.
  • Length: Unless you have an album title that exceeds 100 characters in length counting the spaces, do not change the length.
Note In Base the maximum length of each field must be specified on creation. It is not easy to change this later, so if in doubt specify a greater length. Base uses VCHAR as the field format for text fields. This format only uses the actual number of characters in a field up to the limit set. So, a field containing 20 characters will only use space for 20 characters even if the limit is set at 100. So, two album titles containing 25 and 32 characters respectively will use space for 25 and 32 characters and not 100 characters.
  • Artist: Use the Default setting. And since music has authors, set Entry Required to Yes.
  • Date Purchased: Length: default setting. Entry required should be No. (You may not know the date.)
  • Format: Only change the Entry Required setting: from No o Yes.
  • Notes: No changes are required.
  • NumberofTracks: Change the Field Type to Tiny Integer[TINYINT]. Your allowable number of tracks will be 999.
    • Photo: Use the default settings. When you have finished, click Next.
Note Each field also has a Field Type. In Base the field type must be specified. These types include text, integer, date and decimal. If the field is going to have general information in it (for example a name or a description) then you want to use text. If the field will always contain a number (for example a price) the type should be decimal or another appropriate numerical field. The wizard picks the right field type, so to get an idea of how this works, see what the wizard has chosen for different fields.

Step 3: Set primary key.

  1. Create a primary key should be checked.
  2. Select option Use an existing field as a primary key.
  3. In Fieldname' drop down list, select CollectionID .
  4. Check Auto value if it is not already checked.
  5. Click Next.
Note A primary key uniquely identifies an item (or record) in the table. For example, you might know two people called “Randy Herring" or three people living at the same address and the database needs to distinguish between them.
The simplest method is to assign a unique number to each one: number the first person 1, the second 2 and so on. Each entry has one number and every number is different, so it is easy to say “record ID 172". This is the option chosen here: CollectionID is just a number assigned automatically by Base to each record of this table.
There are more complex ways of doing this, all answering the question “How do I make sure that every single record in my database can be uniquely identified?"

Step 4: Create the table.

  1. If desired, rename the table at this point. If you rename it, make the name meaningful to you. For this example, make no changes.
  2. Leave the option Insert data immediately checked.
  3. Click Finish to complete the table wizard. Close the window created by the table wizard. You are now back to the main window of the database with the listing of the tables, queries, forms, and reports.

Creating a table by copying an existing table

If you have a large collection of music, you might want to create a table for each type of music you have. Rather than creating each table from the wizard, you can make a copy of the original table. Each table can be named according to the type of music contained in it. Possible names could include Classical, Pop, Country and Western, and Rock among others.

  1. Click on the Tables icon in the Database pane to see the existing tables.
  2. Right-click on the CD-Collection table icon. Select Copy from the context menu.
  3. Move the mouse pointer below this table, right-click, and select Paste from the context menu. The Copy table window opens.
  4. Change the table name to Pop and click Next.
  5. Click the >> button to move all the Fields from the left window to the right window and click Next.
  6. Since all the Fields already have the proper File Type formating, no changes should be needed. However, this is the time and place to make these changes if they are needed. (See Caution below for the reason why.) Click Create. The new table is created.
Caution
inline:graphics13.png
Once tables have been created using the wizard, editing them is limited. The Primary key can not be changed in any way. It is possible to add new fields and remove fields. It is possible to change the field type when creating the field as well as later as long as it is not the primary key. Once data has been added to the database, deleting a field will also delete any data contained in that field. When creating a new table, it pays to create the fields with the correct names, length and format before data is added.
Caution
inline:graphics12.png
Tables can be deleted in a very simple way. But doing so removes all of the data contained in every field of the table. Unless you are sure, do not delete a table.
To delete a table, right-click it in the list of tables. Select Delete from the context menu. A pop up window asks if you are sure you want to delete the table. Once you click Yes, the table and its data are gone forever unless you have a backup.

Creating tables in Design View

Design View is a more advanced method for creating a new table. It allows you to directly enter information about each field in the table. We will use this method for the tables of our database.

Note While the Field type and formatting are different in Design View, the concepts are the same as in the Wizard.

The first table to be created is Fuel. Its fields are FuelID, Date, FuelCost, FuelQuantity, Odometer, and PaymentType. FuelCost uses currency and two decimal places. FuelQuantity and Odometer uses the number format with 3 decimal places and 1 decimal place respectively. PaymentType uses the text format.

  1. Click Create Table in Design View.
  2. FuelID entries:
  3. Enter FuelID as the first Field Name.
  4. Select Integer[INTEGER] as the Field Type from the dropdown list. (The default setting is Text[VARCHAR].)
Tip Shortcut for selecting from the Field Type dropdown list: use the key for the first letter of the choice. This might require using the letter more than once to get the choice you want. You can cycle through the choices for a given letter by repeatedly using that letter.
After typing the name of the field in the Fields column, use the Tab key to move to the Field Type column. This will enter the field name and highlight the dropdown list. You can then use the key for the first letter of your choice to select the field type. Just remember to use it the correct number of times if necessary.
  1. Change the Field Properties in the bottom section.
  • Change AutoValue from No to Yes (Figure 5).
inline:Frame6.png
  1. Set FuelID as the Primary key.
  • Right-click on the green triangle to the left of FuelID (Figure 6).
inline:Frame26.png
  • Click Primary Key in the context menu. This places a key icon in front of FuelID.
Note The primary key serves only one purpose. Any name can be used for this field. It is not necessary to use FuelID as the name of the primary key field. We have used it so we know to which table it belong by its name.
  1. All other entries:
    1. Enter the next field name in the first column (Field Name column).
    2. Select the Field Type for each field.
    • For Date use Date[DATE]. (Use the D key once to select it.)
    • PaymentType uses Text[VARCHAR], the default setting.
    • All other fields use Number[NUMERIC]. (Use the N key once to select it.)
    1. Select the Field Properties (Figure 7).
inline:Frame31.png
    • FuelCost, FuelQuantity, and Odometer need changes in the Field Properties section (Figure 7).
    • FuelQuantity: Change Length to 6 and Decimal places to 3. (Many fuel pumps measure fuel to thousands of a gallon in the USA where I live.)
    • Odometer: Change the Length to 10 and the Decimal places to 1.
    • FuelCost: Change the Length to 5 and Decimal places to 2. Click the Format example button. This opens the Field Format window (Figure 8).
inline:Frame5.png
  • Use Currency as the Category and anything in the Format list with two decimal places.
    1. Repeat these steps for each field in the table.
To access additional formatting options, click the button to the right of the Format example panel (Format example button).
    1. Description' can be anything, or can be left blank. (Figure 9 is an example of this.)
    2. To save and close the table, select File '>' Close. Name the table Fuel.
inline:Frame32.png

Follow the same steps to create the Vacations table. The fields and their field types are listed in Figure 9. Make sure you make Date field the primary key before closing, naming the table Vacations, and saving it.

Creating tables for the list box

When the same information can be used in several fields, design a table for each type of information. Each table will contain two fields: the information field, and ID in this order.

  1. Follow the directions in #Creating tables in Design View. In the table we will create, the two fields can be Type and PaymentID. Make sure that the AutoValue is set to Yes for the PaymentID field. Set the PaymentID field as the primary key. (See Figure 10.)
  2. Save the table using the name Payment Type.
inline:Frame12.png
Note: If you have several tables to create with the same fields, design one table and produce the other tables by cutting and pasting. (See “Creating a table by copying an existing table" on page 7.)

Adding data to the list table

List tables do not require a form. Instead, add their data directly to the table. In this example, use the names of the two people with a bank card and cash for cash purchases.

  1. In the main database window, click on the Tables icon (Figure 2). Right-click on Payment Type and select Open from the context menu.
  2. Enter Dan in the first row. Use the tab key to move to the second row.
  3. Enter Kevin in the second row.
  4. Enter Cash in the third row.
  5. Save and close the table window.
Tip The Enter key can also be used to move from field entry to field entry. For this example, enter Jan. in the first Name field. Enter moves the cursor to the ID field. Enter then moves the cursor to the second Name field.
The Down Arrow key can also be used to move from row to row.
Note The PaymentID field contains <'AutoField'> until you use the Enter key to move to the second row. Then it becomes a 0. As you add the entries to each row, the rows of the PaymentID field change to consecutive whole numbers. For example the first three numbers in this field are 0,1,2.

Creating a View

A View is a query. Because of this, the details of how to create and use a View are in the Creating queries section.

inline:Frame7.png

A View is also a table. Its fields come from the fields of one or more tables of the database. It provides a way to look at a number of fields without regard to the table to which any of the fields belong. A View can consists of some of the fields on one table as in Figure 11. Or, it can consist of fields from more than one field as in Figure 12.

inline:Frame8.png
Caution
inline:graphics8.png
Data can not be entered into a View like it can be added to a table. It is strictly for viewing data which has already been added.

Defining relationships

Now that the tables have been created, what are the relationships between our tables? This is the time to define them based upon the questions we asked and answered in the beginning.
When on vacation, we want to enter all of our expenses all at one time each day. Most of these expenses are in the Vacations table, but the fuel we buy is not. So, we will relate these two tables using the Date fields. Since the Fuel table may have more than one entry per date, this relationship between the Vacations and Fuel tables is one to many. (It is designated 1:n.)
The Vacations tables also contains several fields for the type of payment used. For each field listing the payment type, there is only one entry from the Payment Type table. This is a one to one relationship: one field in one table to one entry from the other table. (It is designated 1:1.) Other tables also contain fields for the type of payment. The relationship between these fields of those tables and the Payment Type table are also 1:1.
Since the Payment Type table only provides a static list, we will not be defining a relationship between the Payment Type table and the fields of the other tables which use the entries of the Payment Type table. That will be done when the forms are created.
The Fuel and Maintenance tables do not really have a relationship even though they share similar fields: Date, and Odometer. Unless a person is in a habit of regularly getting fuel and having their vehicle serviced, the entries in these tables do not share anything in common.
Tip As you create your own databases, you need to also determine where tables are related and how.
inline:Frame35.png
We begin defining relationships by Tools > Relationships. The Automobile - OpenOffice.org Base: Relation design window opens (Figure 13). The icons we will use are Add Tables and New Relation.
  1. Click the Add Tables icon. The Add Tables window opens.
  2. There are two ways to add a table to the Relation design window.
  • Double-click the name of the table. In our case, do this for both Vacations and Fuel.
  • Or, click the name of the table and then click Add.
  1. Click Close when you have added the tables you want (Figure 13).
inline:Frame36.png
  1. Defining the relationship between the Vacations and Fuel tables.
  2. Two ways exist to do this:
  3. Click and drag the Date field in the Fuel table to the Date field in the Vacations table. When you release the left mouse button, a connecting line forms between the two date fields (Figure 15).
inline:Frame37.png
  1. Or, click the New Relation icon. This opens the Relations window (Figure 16). Our two tables are listed in the Tables involved section.
  2. In the Fields involved section, click the dropdown list under the Fuel label.
inline:Frame38.png
  1. Select Date from the Fuel table list.
  2. Click in the cell to the right of this dropdown list. This opens a dropdown list for the Vacations table.
  3. Select Date from the Vacations table list. It should now look like Figure 17.
  4. Click OK.
inline:Frame39.png
  1. Modifying the Update options and Delete options section of the Relation window.
  2. Right-click the line connecting the Date fields in the two table lists to open a context menu.
  3. Select Edit to open the Relation window (Figure 18).
  4. Select Update cascade.
  5. Select Delete cascade.
inline:Frame40.png

While these options are not absolutely necessary, they do help. Having these options selected permits you to update a table that has a relationship defined with another table. It also permits you to delete a field from the table.

XXXXXXXXXXX

'Creating queries'Creating queries


Queries are used to get specific information from a database. Using our CD-Collection table, we will create a list of albums by a particular artist. We will do this using the Wizard. The information we might want from the Fuel table includes what our fuel economy is. We will do this using the Design View.
Note Queries blur the differences between a database and a data source. A database is only one type of data source. However, searching for usable information from a data source requires a query. Since the query (one part of a database) does this, the data source appears to become one part of that database: its table or tables. Query results, themselves, are special tables within the database.
Using the Wizard to create a query
Queries created by the wizard provide a list or lists of information based upon what one wants to know. It is possible to obtain a single answer or multiple answers, depending upon the circumstances. Queries which require calculations are best created with the Design view.
In the main database window (Figure 2), click the Queries icon in the Databases section, then in the Tasks section, click Use Wizard to Create Query. The Query Wizard window opens (Figure 66). The information we want is what albums are by a certain musical group or individual (the album's author). We can include when each album was bought.
Note When working with a query, more than one table can be used. Since different tables may contain the same field names, the format for naming fields in a query is Table name and field name. A period (.) is placed between the table name and the field name.
inline:Frame19.png 
Step 1: Select the fields.
    1. Select the CD-Collection table from the dropdown list of tables.
    2. If the Tables selection is not Table: CD-Collection, click the arrow (circled in red in Figure 66).
    3. Click Table: CD-Collection in the list to select it.
    4. Select fields from the CD-Collection table in the Available fields list.
    5. Click AlbumTitle, and use the > button (black oval in Figure 66) to move it to the Fields in Query list.
    6. Move the Artist and DatePurchased fields in the same manner.
Tip To change the order of the fields, select the field you want to move and click the up or down arrow to move it up or down (circled in magenta in Figure 66).
    1. Use the up arrow to change the order of the fields: artist, album, and date purchased.
    2. Click the CD-Collection.Artist field.
    3. Click the up arrow to move it above CD-Collection.AlbumTitle.
inline:Frame78.png
    1. Click Next.
Step 2: Select the 's'orting order.
Up to four fields can be used to sort the information of our query. A little simple logic helps at this point. Which field is most important?
In our query, the artist is most important. The album title is less important, and the date purchased is of least importance. Of course, if we were interested in what music we bought on a given day, the date purchased would be the most important.
inline:Frame77.png
    1. Click the first Sort by dropdown list.
    2. Click CD-Collection.Artist to select it.
    3. If you want the artists to be listed in alphabetical order (a-z), select Ascending on the right. If you want the artist listed in reverse order (z-a), select Descending on the right (Figure 68).
    4. Click the second Sort by dropdown list.
    5. Click CD-Collection.ArtistTitle
    6. Select Ascending or Descending according to the order you want.
    7. Repeat this process for CD-Collection.DatePurchased.
    8. Click Next.
Step 3: Select the 'search conditions'.
The search conditions available are listed in Figure 69. They allow us to compare the name we entered with the names of the artist in our database and decide whether to include a particular artist in our query or not.
inline:Frame79.png
    • is equal to: the same as
    • is not equal to: not the same as
    • is smaller than: comes before
    • is greater than: comes after
    • is equal or less than: the same as or comes before
    • is equal or greater than: the same as or comes after
    • like: similar to in some way
Note These conditions apply to numbers, letters (using the alphabetical order), and dates.
    1. Since we are only searching for one thing, we will use the default setting of Match all of the following.
    2. We are looking for a particular artist, so select is equal to.
    3. Enter the name of the artist in the Value box. Click Next.
Step 4: Select type of query.
We want simple information, so the default setting: Detailed query is what we want. Click Next at the bottom of the window.
Note Since we have a simple query, the Grouping and Grouping conditions are not needed. Those two steps are skipped in our query.
Step 5: Assign aliases if desired.
We want the default settings. Click Next.
Step 6: Overview.
Name the query (suggestion: Query_Artists). To the right of this are two choices. Select Display Query. Click Finish.
Step 7: 'Modify' the query.
We are skipping this step since we have nothing to modify. If you select the Modify Query choice, the query would open in Design view. To make modifications, follow the instructions in the next section, “Using the Design View to create a query".
'Using the Design View to create a query'Using the Design View to create a query

Creating a query using Design View is not as hard as it may first seem. It may take multiple steps, but each step is fairly simple.

What fuel economy is our vehicle getting (miles per gallon in the USA)? This question requires creating two queries, with the first query being used as part of the second query.

Caution
inline:graphics72.png
The procedures we will be using only work with relational databases. This is because of how relational databases are constructed. The elements of a relational database are unique. (The primary key insures this uniqueness.) That is, there are no two elements which are exactly alike. This allows us to select specific elements to place into our queries. Without the elements of the relational database being unique from all other elements, we could not perform these procedures.
'Step 1: Open the first query in Design View'.
Click Create Query in Design View.
Step 2: 'Add tables.'Add tables.
inline:Frame20.png
    1. Click Fuel to highlight it.
    2. Click Add.
    3. Click Close.
Tip Move the cursor over the bottom edge of the fuel table (Figure 71). The cursor become a single arrow with two heads. Drag the bottom of the table to make it longer and easier to see all of the fields in the table.
inline:Frame21.png
'Step 3: Add fields to the table at the bottom'.
    1. Double-click the FuelID field in the Fuel table.
    2. Double-click the Odometer field.
    3. Double-click the FuelQuantity field.
The table at the bottom of the query window should now have three columns (Figure 72).
inline:Frame23.png
'Step 4: Set the criterion for the query'.
We want to the query's FuelID to begin with the numeral 1.
    1. Type >0 in the Criterion cell under FuelID in the query table
    2. Click the Run Query icon in the Query Design toolbar. This icon is circled in red in Figure 73.
inline:Frame22.png
Figure 74 contains the Fuel table with my entries and the query results based upon the Fuel table.
inline:Frame80.png
Step 5: Save and close the query.
Since this query contains the ending odometer reading for our calculations, name it End-Reading when saving it. Then close the query.
Step 6: Create the query to calculate the fuel economy.
    1. Click Create Query in Design View to open a new query.
    2. Add the Fuel table to the query just as you did in step 2: Add tables. But, do not close the Add Tables window.
    3. Add the End-Reading query to this query.
    4. Click the Query radio button to get the list of queries in the database (Figure 75).
inline:Frame24.png
    1. Click End-Reading.
    2. Click Add, and then click Close.
'Step 7: Add' fields to the table at the bottom of the query.
inline:Frame25.png
We are going to calculate the fuel economy. To do this we need the FuelQuantity and distance traveled. Since the FuelQuantity we want to use is at the ending odometer reading, we will use the End-Reading query to get it. We will also use the Odometer field from the Fuel table and End-Reading query.
    1. Double-click FuelQuantity in the End-Reading query.
    2. Double-click Odometer in the End-Reading query.
    3. Double-click Odometer in the Fuel table.
inline:Frame81.png
'Step 8: Enter the FuelID difference field'.
We want the difference between the FuelID value of the Fuel table and FuelID value of the End-Reading query to equal one (1).
    1. Type "End-Reading".FuelID - Fuel.FuelID in the field to the right of the Odometer field of the Fuel Table (Figure 78).
Type the numeral 1 (one) in the Criterion cell of this column.
Caution
inline:graphics83.png
When entering fields for these calculations, you must follow this format: table or query name followed by a period follow by the field name. For hyphenated or multiple-word names (table or query), use double quotes around the table or query name. The query will then add the rest of the double quotes as in Figure 78.
Use the arithmetical symbol between the two. More than one calculation can be done by using parentheses to group the arithmetical operations.
inline:Frame82.png
    1. Calculate the distance traveled (Figure 79):
    • Type "End-Reading".Odometer - Fuel.Odometer in the Field cell.
    • Type >0 in the Criterion cell.
inline:Frame83.png
    1. Calculate fuel economy (Figure 80):
    2. Type ("End-Reading".Odometer - Fuel.Odometer)/"End-Reading".FuelQuanity in the Field in the next column to the right.
inline:Frame84.png
'Step 9: Run the query and make some modification'.
After we run the query to make sure it works correctly, we will hide all of the fields that we do not need.
    1. Click the Run Query icon in the Design Query toolbar. (Figure 73) The results are in Figure 81.
inline:Frame85.png 
Notice that not all of the last column label is visible because some of the labels are long. We can fix this problem by using an alias for many of the fields. The labels are replaced by their aliases.
    1. Add Aliases: Type in aliases as they are listed in Figure 82.
inline:Frame87.png
    1. Run the query again. The results are in Figure 83.
inline:Frame86.png 
We really do not need the column showing the difference between the FuelID fields from the table and query. So, we will hide it. While it will not be visible, it will still be used in the calculations.
    1. Hide a field that does not need to be seen.
Remove the check in the box of the Visible cell as in Figure 84.
inline:Frame88.png
    1. Rerun the query (Figure 85).
inline:Frame89.png
Step 10: Close, save, and name the query.
My suggestion for a name is Fuel Economy.
There are obviously other calculations that can be made in this query such as cost per distance traveled and how much of the cost belongs to each of the payments types.
Note To fully use queries requires a knowledge of mathematics and specifically set operations (unions, intersections, and, or, complements, and any combinations of these). For example, we listed all of our criteria in one row. That means that all of these criteria have to be met before a row of values will be created in the query. This is how the and operator works on sets.
It also requires having a copy of the Hsqldb User Guide available from http://hsqldb.org/.

Creating reports


Reports provide information found in the database in a useful way. In this they are similar to queries. Reports are generated from the database's tables or queries. They can contain all of the fields of the table or query or just a selected group of fields. Reports can be static or dynamic. Static reports contain the data in the selected fields at the time the report was created. Dynamic reports can be updated to show the latest data.
For example, a report on vacation expenses divided into categories should probably be a static report because it is based upon specific data that does not change. However, a report on the fuel data should probably be a dynamic report, because this report depends upon data that does change.
Caution
inline:graphics91.png
All reports are based upon a single table or query. So you need first to decide what fields you want to use in the report. If you want to use fields from different tables, you must first combine these fields in a single query. Then you can create a report on this query.
An example of this caution is creating a report on vacation expenses. Fuel costs are one part of that report as are meal costs. These values are contained in fields of two different tables: Vacations and Fuel. So this report requires creating a query.
Creating a 'static' report
We will create a report on vacation expenses. Certain questions need to be asked before creating the report.
    • What information do we want in the report?
    • How do we want the information arraigned?
    • What fields are required to provide this information?
    • Will a query have to be created because these fields are in different tables?
    • Are there any calculations required in the data before being added to the report?
The expenses for our vacation are motel, tolls, miscellaneous, breakfast, lunch, supper, snacks, and fuel. One possible report would simply list the totals of each of these expense groups. Another possible report would list the expense totals for each day of the vacation. A third possible report would list the totals for each expense group for each type of payment. (This would let us know where the money came from to pay the expenses.) At the present time, using the data from the queries in a spreadsheet is the best way to handle reports like this. In the near future, the report feature will include these abilities.
For our purposes, we will create two reports. The first one will list the expenses each day other than fuel. The second report will list the fuel costs each day.
The fields we will need for the first report from the Vacations table are: Date, Motel, Toll, Breakfast, Lunch, Supper, SnackCost, and Miscellaneous. This report will not require an additional query.
The second report involves the Fuel table. Since fuel was purchased and entered into this table at times other than during the vacation, a query needs to be created that contains only the fuel purchased during the vacation.
Vacations table report
    1. Create a new report.
    2. Click the Reports icon in the Database list in the Automobile - OpenOffice.org window (Figure 2).
    3. In the Tasks list, click Use Wizard to Create Report. The Report Wizard window opens.
    4. Select the fields.
    5. Select Table: Vacations in the Tables or Queries dropdown list.
    6. Use the > to move these fields from the Available fields list to the Fields in report list: Date, Motel, Tolls, Miscellaneous, Breakfast, Lunch, Supper, and SnackCost (Figure 86). Click Next.
inline:Frame90.png
    1. Label the fields.
Shorten Miscellaneous to Misc. Click Next.
    1. Group fields.
Since we are grouping by the date, use the > button to move the Date field to the Grouping list. Click Next.
inline:graphics93.png
    1. Sort options.
We do not want to do any additional sorting. Click Next.
    1. Choose layout.
We will be using the default settings for the layout. Click Next.
Note If you feel adventurous, try selecting some of the other layout choices. After selecting a choice, drag and drop the Report Wizard window so that you can see what you have selected. (Move the cursor over the Heading of this window, and then drag and drop.)
    1. Create report.
    2. Label the report: Vacation Expenses.
    3. Select Static report.
    4. Click Finished.
Vacation fuel report
    1. Create a query containing only fuel bought on the days of the vacation.
    2. Open a query in Design View.
    3. Follow the steps for adding tables in Add tables. Add the Fuel table.
    4. Double-click these fields in the Fuel table listing: Date and FuelCost to enter them in the table at the bottom of the query.
    5. In the Criterion cell of the Date field, type the following:
BETWEEN #5/25/2007# AND #5/26/2007#
inline:Frame92.png
    1. Save, name, and close the query. (Suggestion: Vacation Fuel Purchases.)
Tip When using dates in a query, enter them in numerical form MM/DDYYYY or DD/MM/YYYY depending upon your language's default setting for dates (my default setting is MM/DD/YYYY).
All dates must have a # before and after it. Hence, May 25, 2007 is written #05/25/2007#.
    1. Open a new report.
    2. Right-click the Vacation Fuel Purchases query.
    3. Select Report Wizard from the context menu.
Note When a new report is opened in this way, the query used to open it is automatically selected in the Tables or Queries dropdown list.
    1. Create the report.
Use >> to move both fields from the Available Fields to the Fields in Report list. Click Next.
    1. Label fields.
Add a space to FuelCost to make it Fuel Cost (two words). Click Next.
    1. Group fields.
    2. Click Date to highlight it.
    3. Use > to move the Date field to the Groupings list. Click Next.
    4. Choose layout.
We will be making no changes in the layout. Click Next.
    1. Create report (final settings).
    2. Use the suggested name, which is the same as the query.
    3. Select Static report. Click Finish.
Creating a 'dynamic' report
We will create a report with some statistics on our fuel consumption. To do this, we have to modify two queries: End-Reading and Fuel Economy. We will be adding the FuelCost field to the End-Reading query. Then we will add the FuelCost field from the End-Reading query to the Fuel Economy query.
Tip When opening a query to edit it, it might appear as in Figure 88. If you move your cursor over the black line (circled in red), it becomes a double headed arrow. Drag and drop it to a lower position.
inline:Frame34.png
    1. Add the FuelCost field to the End-Reading query:
    2. Right-click the End-Reading query and select Edit from the context menu.
    3. In the Fuel table list, double-click to add FuelCost to the bottom table (Figure 89).
    4. Save and close the query.
inline:Frame27.png
    1. Add the FuelCost field from the End-Reading query to the Fuel Economy query.
    2. Right-click the Fuel Economy query and select Edit from the context menu.
    3. Double-click the FuelCost field in the End-Reading query list to the table at the bottom.
    4. Add a calculation field to the right of the FuelCost field.
    5. Type the following in the Field cell:
"End-Reading".FuelCost/("End-Reading".Odometer - Fuel.Odometer)
    1. Type the following in the Alias cell:
cost per mile
Note If you use the metric system, cost per km is the appropriate alias.
    1. Save and close the query.
    2. Open a new report.
Right-click the Fuel Economy query and select Report Wizard.
    1. Select fields.
Move all the fields from the Available fields to the Fields in report list. Use the >> to do so. Click Next.
    1. Label fields.
Change FuelCost to Fuel Cost by placing a space between the words. Click Next.
    1. Group fields.
Use > to move the Date field to the Groupings list. Click Next.
    1. Sort options: the wizard skipped this one.
    2. Choose layout.
Accept the default. Click Next.
    1. Create the report.
    2. Change the report name to Fuel Statistics.
    3. The default setting is Dynamic report, so no change is necessary.
    4. Select Modify report layout. Click Finish.
Modifying a report
At the end of the last section, we left the Fuel Statistics report open in the edit mode (Figure 90). We will be working on that report. These same steps can be used with any report that you open for editing.
inline:Frame93.png
The Author is the name you listed in Tools > Options > OpenOffice.org > User Data. The date is not correct. The columns need to be moved to the left to give a better appearance. None of the numbers are correct, but their only purpose is to show the number of decimal places.
Step 1: Change the date.
    1. Click to the right of the date (4/26/20) so that the cursor is next to the field. Use the Backspace key to erase the date.
    2. Insert > Fields > Date. This places today's date where the original date was.
    3. Changing the date formating:
    4. Double-click the date field you just inserted. The Edit Fields: Document window opens (Figure 91).
inline:Frame94.png
    1. Since this is a dynamic report, change the Select field from Date (fixed) to Date.
    2. Change the Format to what you desire. (I use the Friday, December 31, 1999 choice.) Click OK.
Step 2: Change the column widths.
The column widths can be changed by moving the cursor over the right border of each column so that it becomes a double-headed arrow. Then drag and drop it where you want it. This has to be done for each column in each table in the report. This can also be done with the last column on the right even though there is no black border. It should now look something like Figure 92.
inline:Frame95.png
'Step 3: Change the number formating in the cells'.
The fuel quantity should have three decimal places. The Begin, End, and Distance should have one decimal place. Fuel Cost should be currency and have two decimal places, and Cost per mile should have three decimal places.
    1. Right-click the cell below Quantity to open the context menu. (The cell is circled in red in Figure 92.)
    2. Select Number format.
    3. In the Options section (Figure 93),
    4. Change the number of Decimal places to 3.
    5. Click the green checkmark. Click OK.
inline:Frame96.png
    1. Change the Fuel Cost field.
    2. Right-click in the cell below Fuel Cost.
    3. Select Number Format.
    4. In the Category list, select Currency. Click OK.
    5. Change the Cost per mile field.
    6. Right-click in the cell below Cost per mile.
    7. Select Number Format.
    8. In the Category list, select Currency.
    9. In the Option section:
    10. Set the number of decimal places to 3.
    11. Click the green checkmark.
    12. Click OK.
Step 4: Save and close the report.
Double-click the report. It should now look like Figure 94.
inline:Frame98.png 


Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools