Point & Click OpenOffice. org.
Authors: Miller R.
Published year: 2003
Pages: 85-86/143
Buy this book on amazon.com >>

Accessing a Data Source in Writer or Calc

Follow these steps to grab data from your database and insert it into your Writer documents.

Select New > Text Document. The procedures work almost exactly the same way for Calc.

Select Data Sources under the View tab. A new window appears with a listing of all the registered database names . Click Data Sources again to hide the window.

In the data sources window, click the database you set up in Base. Click the + in a box to the left of the Tables icon to show which ones are available. Click the table name to make the records appear. The sample database includes only the name , street, city, state, and zip.

Using the data sources window to insert data into a document.

To paste a field from the database into your document, click the record field and drag it where you want it in the Writer editing window. In this example, the George, Herb, and Rich names are individually pulled down into the customer list.

Dragging data into the document.

Click the box in the table's upper-left corner (just left of the names) to highlight all the fields. Then click the Data to Text button (the icon to the right of the funnel iconstext with little right arrow). Use the resulting window to drag down the fields as a table, fields, or text.

Dragging data as a table, fields, or text.

Enable the Text radio button, and then select and arrange the fields.

Arranging fields with the Text radio button.

Click OK. The contents of each record are copied into the document. This is a great way to make a list of addresses. Use this technique with other types of data to make basic text-oriented reports. Regular corporate-level reports will be discussed a little later.

Copying the contents of each record into a document.

Highlighting a row (clicking the box to the left of the first field) and then clicking the Data to Text button copies the contents of that row into your document.

Copying a row of data into your document as text.

To create a table in your document instead of formatted text lists, use the Table radio button under the "data to text" button. This example uses only the name and city fields.

Copying a row of data into your document as a table.



Formulating SQL QueriesEven if You Know Nothing About Databases

A query picks out certain types or groups of data within a database for use in your document (or for any purpose, for that matter). This saves you the trouble of manually looking through all the records to find just what you want. Use the wizard to help set up SQL queries in OOo. Here's how it's done.

Click the Windows tab and select your Base file.

Click the Queries icon in the Database pane at the left. In the Tasks pane, select Use Wizard to Create Query.

The main Base query screen.

In the field selection screen, choose the desired table from the Tables dropdown menu. Choose your fields by selecting a field and then clicking the right arrow to move the field to the Fields in the Query window. Click Next .

The field selection screen.

Choose the sort order in step 2. Pick a field from the Sort by dropdown menu. Secondary fields are sorted using the Then by dropdown menu. Click Next.

The sorting order screen.

In step 3 you can conditionally select which fields will be displayed. For instance, if you want to show records with a field that is a certain value, you could query for the value here.

Steps 4 through 7 deal with more selection options. In our example, click Next to get to the Overview step.

The search conditions screen.

Use the overview screen to name your query, and then click Finish. The query runs and produces the results in a regular spreadsheet-style screen.

The query produces the results.

An SQL query whittles data into manageable chunks . Switch back to the Writer document via the Window tab. The query results appear when you click the + next to the Query icon. The database itself is visible via the View button and the Datasources menu item.

The next step is to create a printable report.


Point & Click OpenOffice. org.
Authors: Miller R.
Published year: 2003
Pages: 85-86/143
Buy this book on amazon.com >>