Title: Using Data Sources: 1.0 First Edition: November 2004
Title: Using Data Sources: 1.0 First Edition: November 2004
Title: Using Data Sources: 1.0 First Edition: November 2004
Overview
OpenOffice.org doesn't have a database server capability (limited ability to create and work
with dBase format files), but it does have a great integrated1 client ability.
This chapter introduces the concepts and tools required to work with data sources. More
advanced topics are found in other documents, some of which are referenced from this one.
Note to Microsoft Access users: To replace Access entirely requires transferring .mdb
(Access' own proprietary format) files to another database server such as MySQL. For
information on how to do this, see: http://mdbtools.sourceforge.net/. To keep database files in
.mdb format, use ODBC to connect to the files. See
http://www.openoffice.org/FAQs/mostfaqs.html#10.
Feedback
Please direct any comments or suggestions about this document to:
authors@user-faq.openoffice.org.
Acknowledgments
Some of this material is based on work by Scott Carr and Daniel Strome.
1 The term integrated is used here to reflect that it isn't a separate application but works in with all the applications
in OpenOffice.org.
5) Double-click the field name(s) that have the data you want to limit the query to. For
example, the field name might be “Keyword” and only records containing “Friend” are
desired.
6) Un-check the visible checkbox for these criteria fields. (This is not necessary but it
saves getting the field repeated in the final table.)
7) Type the criteria into the Criterion row. For example, 'friend' or if there might be other
text in the field for the record but it must contain the word 'friend' somewhere in the
field type “LIKE '*friend*' ”.
8) Check the query by clicking the Run query button . To adjust the various panes,
click and drag pane borders to get a desired arrangement.
9) File > Save As and name the query.
10)File > Close Window.
Database forms
This section is based upon a document by Daniel Strome, titled “How to Link Tables Using
Named Parameters”. The full document is available for download from
http://documentation.openoffice.org/HOW_TO/index.html. (There is a section in the
document about running a macro, but this is no longer necessary.)
This section is only a very brief look as OpenOffice.org provides a full graphical user
interface as a database client. Refer to the Database Guide for more details.
Form use
When using a form a Navigation toolbar should be visible (by default across the bottom of
the window). If it is not visible, right-click any toolbar and select Navigation bar. The
controls on this form are similar to those used in Access.
Note1: Doing a find is slow because it is handled by OpenOffice.org rather than the database
server (lot of information passing). Use filters instead.
Note2: If the table is read-only then it could be because:
OpenOffice.org requires a primary key (or bookmark facility) for the table, or
OpenOffice.org hasn't implemented writing to text or spreadsheet files, or
The database driver isn't providing the required privileges – try updating the database driver (it
may be that you don't have sufficient privileges).
• To change the order that the fields are accessed when entering data and pressing Tab,
click Activation order.
Adding a sub-form
A sub-form is where the records displayed in the sub-form are dependent on the record
displayed in the main form. The two tables must have a common field. For example, the main
form might be customers’ details and the sub-form the orders for that customer; the fields in
common might be a customer identity.
To add a sub-form:
1) Display the Form navigator: Click Form Navigator on the Form Functions toolbar.
2) The Form Navigator displays a tree of forms and their controls. Click on the form
(second level - maybe called “Standard”).
3) Right click on the form > New > Form.
Note: It is very important that it is a sub-form in the hierarchy, otherwise this will not
work.
4) Optionally rename the sub-form.
5) With the sub-form selected in the Form navigator, click Table Control.
6) Drag a box in the document.
7) If AutoPilots is turned on, select the data source again, but this time select the new
table and then its fields. If AutoPilots is turned off, specify the data source for the form
in the Forms Properties window, then add columns by right-clicking in the top row of
the control > Insert Column > Textbox. Change the properties of the column by right
clicking it > Column...
8) Display the data properties for the sub-form: With the table control selected > click
Form Properties > Data.
9) Change the content type to SQL Command.
10)Enter into content something like:
SELECT * FROM Orders WHERE CustId = :x
Where Orders = the name of the second table, CustId is the name of the field within
that table that has the values in common with the table for the main form, and x is any
variable name.
11)Scroll to the bottom of the list.
12)In Link master fields, type: CustomerId
Where CustomerId is the name of the field in the table of the main form.
13)In Link slave field, type: x
Where x is the variable used in step 11. Do not type a colon this time!
14)Click Design Mode On/ Off and it should be working.
Report creation
1) File > AutoPilot > Report...
2) Follow the AutoPilot.
3) In the last step (Save Report), choose “Modify report template”.
4) Adjust the column widths. This is a table, so you can drag columns or use Format >
Table... > Columns.
5) Save and close the file.
6) Display the Data source viewer.
7) Navigate to the data source and open Links.
8) Double-click on the report. A new document based on the template will be created.
Note: The report must be closed or nothing will happen.