Intro to the Data Source View

From NeoWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 02:51, 5 November 2007 (edit)
Lorinda (Talk | contribs)
(Using the Standard Filter - write this section)
← Previous diff
Revision as of 03:28, 5 November 2007 (edit) (undo)
Lorinda (Talk | contribs)
(Sorting Data in Data Source View - set up subsections for this part)
Next diff →
Line 113: Line 113:
==Sorting Data in Data Source View== ==Sorting Data in Data Source View==
 +===Quick One-Column Sorts===
 +===Multiple-Column Sorts===
 +===Sorting Queries===
 +
<br> <br>
 +
==Inserting Fields from the Data Source== ==Inserting Fields from the Data Source==
<br> <br>

Revision as of 03:28, 5 November 2007

This article is part of the To Base and Back Again tutorial series.

Reports and Forms are actually Writer documents stored within the odb file of your database. But you can also access the data in registered databases from Writer documents that are not stored within the odb file. This tutorial discusses some of the ways to access and use this data.

Contents

Registering The Database

In order to access data in from Writer, the database must be registered. When you create a new database, the Database Wizard asks if you want to register the new database. Under normal conditions, you want to check Yes. If you accidently checked No, or if you have received an odb file from someone else, here's how to register the database:

  1. In the NeoOffice menu, choose Preferences
  2. Double-click on NeoOffice Base to disclose the sub-categories
  3. Click on Databases. You will see a list of registered databases.
  4. Click the New... button. The Create Database Link window appears
  5. Click the Browse... button and navigate to the database file you want to register.
  6. If desired, you may give it a Registered name different than the file path.
  7. Click OK in the Create Database Link window.
  8. Click OK in the Options-NeoOffice Base-Databases window.


Accessing the Datasource

  1. In an open Writer, document, click on the Data Sources button on the Standard Toolbar, or go to the View menu and select DataSources. The Data Source View opens just below the toolbars, above your document.
  2. In the Data Explorer (the left column with a list of data sources), click on the disclosure triangle next to the name of the database file you want to work with.
  3. Now click on the disclosure triangle next to Queries or Tables under the seleted database name.
  4. Select the specific Query or Table you want to work with for this document. (e.g. the All Sightings query). wait while the data loads. Note that the more complex the query, the longer you will need to wait. (The wait time may also be affected by available memory, CPU load, and processor speed).
  5. Make sure that the Table Data Toolbar is visible at the top of the Data Source View. See #Anatomy of the Data Source View.
    • If this toolbar does not, appear, you will need to move or rename your preferences folder, as there does not seem to be any other way to turn it on from within the program. See the articles on corrupted preferences and Salvaging Settings from Preferences for directions. When I encountered this problem, I narrowed the troublesome spot down to the registry folder. Instead of moving the entire preferences folder, you might try moving/renaming just the registry folder. Note that you will lose data source registrations if you need to do this. See Registering the Data Source.
      Due to the fact that this toolbar cannot be turned back on without moving preferences, DO NOT close the Table Data toolbar.


Anatomy of the Data Source View


Image:DataSources.png

Adjusting the Appearance of the Data

With the Data Source View open, there are several things you can do to change the appearance of the data.

  • To change the formatting data in a particular column (e.g. the Date column in the Field Trips table), right-click or control-click on the column heading (e.g. Date) and select Column Format... from the contextual menu. A Field Format window will open where you can adjust the formatting.
  • To change the font and font formatting used in the table data, right-click or control click on any of the grey "cells" to the left of a record and choose Table Format... from the contextual Menu.
  • To change the width of the column, there are two options:
    Place your cursor on the border between the two columns. The cursor icon will change to a line with arrows pointing left and right. Hold down the mouse button and drag the border to the desired location
    Control-click or right-click on the column heading and choose Column Width... from the contexual menu. In the window that appears, alter the column width as desired.
  • To hide a column (i.e. if you don't need to see/work with that data) control-click or right-click on the column heading and choose Hide Columns from the contextual menu.
    • To show a previously hidden column, control-click or right-click on any column heading and choose Show Columns and then the column you want to show. (Note that Show Columns only appears is one or more columns are actually hidden).
  • To hide the Explorer, click on the Explorer On/Off button on the Table Data Toolbar. (It looks like a folder with a magnifying glass).


Editing Data in Data Source View

In some cases, you can actually edit your data in the Data Source View in Writer.

You can edit data in:
  • Tables that are part of an embedded database (using the HSQLDB engine, as we have done in this tutorial)
You cannot edit data in:
The ability to edit tables in Base files which connect to other database engines will vary. Users who connect to other database engines are encouraged to add details to this section. Make sure to specify connection type. If you don't have a wiki editing account, you may send a private message Lorinda at trinity with the information. (Note that you need to be a registered user at trinity to use its private message function.)
Note: The Edit Data button on the Table Data toolbar must be highlighted to edit data. (It looks like a sheet of paper with a pencil over it). If you don't want to accidentally edit data while working with a data source, click this button to un-highlight it, and you will be unable to edit data. This same button will be dimmed if the current data source type does not permit editing.
  • To edit an existing record in Data Source View, click in the cell containing the data you want to edit. A blinking cursor will appear in the cell and you can edit the contents.
  • To add a record, scroll down to the bottom of the visible data. (Or click on the sunburst icon on the navigation bar at the bottom of the Data Source View). You will see a blank record with a sunburst icon in the far left grey square. Click anywhere in this record, and begin typing to add the new record. (Note that the starburst icon in the far left square moves down one more record as soon as you start typing.)
  • To delete an existing record, control-click or right-click in the small unlabled "cell" on the far left of the data table. Select Delete rows from the contextual menu.

If you are unable to edit your data in the Data Source View, or if you prefer to enter/edit data in the database file itself (for example, field trip and sightings data is best entered in the Field Trips Data Entry form), you can control-click or right click on the icon next to the name of the query, table, or data source in the Explorer and select Edit Database... from the contextual menu.

Filtering Data in Data Source View


Once you have selected the query or table you want to work with, you can filter the data using either the Auto Filter button or the Standard Filter button.

Using Auto Filter

The Auto Filter allows you to quickly filter data. Our examples here use the Sightings table

  1. Click in the cell of a record containing the data you want to filter for. E.G. click in the Field Trip ID column in one of the records.
  2. Click on the AutoFilter button on the Table Data toolbar. (It looks like a butler's vest and tie with a funnel). The Data Source View adjusts to show only those sightings with the same Field Trip ID number as the record chosen in step 1.
  3. To add a second filtering parameter, click in another field column of a record containing the value you want to filter for. For example, click a Voice cell where the checkbox is checked.
  4. Double-click on the Autofilter button on the Table Data toolbar. The Data Source View adjusts to show those sightings (in the already-filtered field trip) where Voice is TRUE.
    Note that while it is only necessary to click the Autofilter button once when no filters are currently applied, you have to double click the Autofilter button to apply additional filters to the currently applied filters.
  5. To stop filtering and see all the data again, click either on the Remove Sort/Filter button (a red hexagon with a white x) or Apply Filter button (a green circle with a checkmark). Note that the Apply Filter button is a toggle. When it is highlighted, the filter is applied, when it is not, there is no filter applied.

Using the Standard Filter

While the Autofilter takes the value of the selected cell, the Standard Filter lets you specify a value without seeing it, and lets you build more complete Filter criteria. Unless otherwise stated, we will work with the All Sightings query for these examples.

  1. With the All Sightings query showing in the Data Sources View, click on the Standard Filter button (the funnel icon) on the Table Data toolbar. The Standard Filter window opens.
  2. Set the desired parameters in the Standard Filter window and click OK
    Some specific examples:
    • To filter for a particular text value:
      1. Set the Field Name drop down to Location name
      2. Set the Condition drop down to Like
      3. In the Value field, type Erehwon. Note that once you click elsewhere, the the text string you entered will be surrounded by single quotes to mark it as text.
    • To filter for a range of dates:
      1. Set the Field Name drop down in the first line to Date
      2. Set the Condition drop down in the first line to >=
      3. In the Value field, type 1/1/1900. Note that one you hit return or click elsewhere, a # will be added to the beginning and end of the date "string" to mark it as a date.
      4. Set the Field Name drop down in the second line to Date
      5. Set the Condition drop down in the second line to <=
      6. In the Value field of the second line, type 12/31/1900.
      7. Make sure the Operator drop-down of the second line is set to AND
        Note that the Operator drop-down is greyed out until one of the other settings on that line have been given a value.
    • To filter for a TRUE value in a Boolean (Yes/No) field
      1. Set the Field Name drop down to Voice
      2. Set the Condition drop down to =
      3. In the Value field, type TRUE.
        Instead of TRUE, you can also enter 1. In some localizations of NeoOffice, TRUE (or the equivalent term in that language) does not work in filter dialogs. Instead, you must use 1 for TRUE and 0 for FALSE.
    • To filter for a FALSE value in a Boolean (Yes/No)field
      1. Set the Field Name drop down in the first line to Male
      2. Set the Condition drop down in the first line to =
      3. In the Value field, type FALSE.
        Instead of FALSE, you can also enter 0. In some localizations of NeoOffice, FALSE (or the equivalent term in that language) does not work in filter dialogs. Instead, you must use 0 for FALSE.
      4. Set the Field Name drop down of the second line to Male
      5. Set the Condition drop down in the second ine to null
      6. Set the Operator drop-down of the second line to OR
      Remember that it is impossible to tell whether an empty check box is a FALSE or a NULL value. This is why it is important to search for FALSE or NULL values.
    • To filter for a NULL (empty) field
      this is helpful to find data that was not entered. For the example, we will work with the Field_Trips table.
      1. Set the Field Name drop down to Wind
      2. Set the Condition drop down in the second line to null
      If you have entered the test data specified earlier in the tutorial, this filter condition will actually return no results, because there are no records will null values in the Wind field. You may wish to create a new entry, or edit an existing entry to see how this works.
  3. To remove the filter, click on the Apply Filter or the Remove Sort/Filter Button.

Sorting Data in Data Source View

Quick One-Column Sorts

Multiple-Column Sorts

Sorting Queries


Inserting Fields from the Data Source


Adding Fields in the flow of your document


Quickly Creating a Writer Table


Using the Next Record Field


Issues with Image Fields

Creating Forms in Writer Documents

Forms are not limited to those stored within an odb file. You can also create a form in an "independent" or "external" Writer document. When working with forms, you do not use the Data Source View.

  1. Make Sure that the Form Controls and Form Design toolbars are visible. If they are not, go to the View menu, choose Toolbars and select the needed toolbars.
  2. Click on the Form button. The Form Properties window should appear.
    You can also reach the Form Properties window by clicking on the Form Navigator button, control-clicking on the name of the form (most likely Standard), and choosiing Properties.
  3. Click on the Data tab.
  4. Click on the ... next to Data Sources and browse to locate the desired data source
  5. Set the Content type for Table or Query, depending on your source. Those familiar with SQL can also choose SQL Command
  6. Select the desired Query or Table from the Content drop-down
  7. Adjust other settings as desired, and close the Form Properties window.

From this point on, editing forms in an independent Writer document should work the same way editing forms stored in he odb file do.

Related Wiki Links

Using the Mail Merge Wizard
Various Form Tutorials in the To Base and Back Again series.

External Links

Personal tools