In the previous two blogs, first you've learned about Form Controls, where you created a Push Button http://blogs.sun.com/oootnt/entry/exploring_hidden_secrets_push_buttons, and then you utilized the built-in wizards to click your way to a DVD Collection database: http://blogs.sun.com/oootnt/entry/exploring_hidden_secrets_creating_a.
May be you followed the steps using your own copy of OpenOffice.org or StarOffice. Then you might have entered some data records to your new DVD collection database.
In this blog, you can see how to create a Writer text document with some database related form controls.
The Writer document is designed to show your database records. Why not just use the ready made Base form? Well, one advantage of a Writer document over a Base form is the full control about layout and formatting, using the well known Writer menus and icons. Another advantage or disadvantage (this depends on your use cases) is the fact that the Base form is always an integrated part of the complete Base file, while the Writer document is an external document that just opens a link to the connected database.
This is the mydvds.odb Base file to start from. We already did enter some data records.
-
Choose File - New - Text Document to open a new Writer document.
-
Enter a heading and some other text as you like.
-
Choose View - Toolbars - Form Controls to open the Form Controls toolbar.
-
On the Form Controls toolbar, click the More Control icon to open the More Controls toolbar.
-
On the More Controls toolbar, click the Table Control icon.
-
Drag a rectangle of the size and position of the new table where your database records will be shown.
The Table Element Wizard opens.
In the Table Element Wizard, select your data source and the Base table to be used.
Click Next for the next page of the wizard.
Double-click the fields that should be shown as columns in the table element. Then click Finish.
Remember that you can click the Design Mode On/Off icon on the Form Controls toolbar to switch from design mode to data entry mode and back.
Found issues: The ReleaseYear field obviously accepts date values in the default date format only. I did enter years like 1999, 2000, 2008, but they got converted to some unwanted values. Or my data did not show up at all, because I clicked the "Next Record" button instead of the "New Record" button when I did enter the records (?). I don't know and this blog is not a bug hunting blog, so let's pretend there are years in the ReleaseYear fields.
In design mode you can control the properties of the table element. A double-click opens the Control Properties window. But the more interesting window is the Form Properties window. Right-click the table element and choose Form.
On the Data tab page you can see that the Table Element Wizard did fill in the correct values for Data Source, Content Type, and Content.
Now let's add two text boxes to display the database fields of the record that is selected in the table element.
-
Switch to design mode (the Design Mode On/Off icon must be enabled)
-
On the Form Controls toolbar, click the Text Box icon.
-
Drag a rectangle where you want to show the first text box.
-
Double-click the new text box to open its Control Properties window.
On the Data tab page, select the Data Field that should be shown in this text box.
Next, switch from design mode to data entry mode and test your new Writer form document.
Do not forget to save the Writer document.
When you close the Writer form document and open it again, it will be ready in data entry mode.

