Inserting Data from the Data Source View into a Writer Document

From NeoWiki

Jump to: navigation, search
This article is part of the To Base and Back Again tutorial series.

Contents

[edit] Inserting Fields from the Data Source


[edit] Adding Fields in the flow of your document

  1. In a new or exisitng Writer document, open the Data Source View (from the View menu, choose Data Sources)
  2. Select the data source and table or query you want to work with
  3. Filter and/or Sort the information as desired.
  4. Drag the field name from the column headers in the table area of the Data Source View to the location in your document where you want it to appear. A field name encased in < > will appear in you document.
    • If you have FIeld Names checked in the View Menu you will not see < or >, instead you will see a field name like BirdDatabase.FieldTrips.Location where the pattern is DatabaseFileName.TableOrQueryName.FieldName.
    • If you have Field Shadings turned on the the View menu, the field names will appear with grey highlighting.
  5. Repeat as often as needed until you have the fields you need in your document.
  6. To see a sample of data in your document:
    1. Make sure that a row of data is selected in the data table of the Data Source View. Do this by clicking in the grey box to the left of the desired row of data.
    2. Click on the Data To Fields button on the Table Data Toolbar.
      Image:TableDataBar.jpg
      • If the Data To Fields button is greyed out, make sure you have selected a row of data.
      • If the Table Data toolbar (shown above) is not visible, try hiding and then showing the Data Sources View. (View menu, Data Sources, then repeat). If it is still not visible, you probably have some corrupt preferences. see the note here for more directions for restoring the Table Data toolbar.
  7. To print or preview, go to the File menu and choose Print (or press Command-P.
  8. A box will appear asking if you want to print form letter. Click on Yes.
    Do not, under any circumstances, check the "Do not show warning again" box. If you do, you will only be able to print documents with field names any time you try to print a document with fields in it. The only way to undo this is to move or rename your preferences file.
  9. In the Mail Merge window that opens, choose your desired settings. Options include:
    • You can filter or sort using the Table Data Bar in in Mail Merge window.
    • You can specify which records you want to print by selecting the desired records. After selecting the desired records, check to make sure that the Selected records radio button has been selected. Sometimes Neo does so automatically, sometimes it does not.
    • You can specify a range of records by number.
    • You can send the resulting files to the printer or to a new File.
      • If you choose File you can also specify the folder you want to save the file to by clickin on the ... button next to the Path field. You have file name autogenerated based on a field, or click on Manual Setting and type the name you want. (Note, however, that you will still see the usual Mac Save dialog when you click OK button, and you will need to respecify the path and the name).
      • If you choose to send the results to the printer, you can specify Single print jobs, where each record will generate a separate print job.

Note That this method creates one copy of the document for each record. If you want all the records to appear in one document, you need to use the Next Record field or create a table.

[edit] Using the Next Record Field

The instructions above will result in one document per record. If you want to see data from more than one record in a single document, you need to use the Next Record Field, as follows. (These instructions assume you have the Data Source View open and your desired query or table selected.)

  1. Go to the View menu. If Field Shadings is not checked, select it to turn it on. (This makes it easier to see the Next Record field)
  2. Drag the field name from the column headers in the table area of the Data Source View to the location in your document where you want it to appear. A field name encased in < > will appear in you document.
    • If you have FIeld Names checked in the View Menu you will not see < or >, instead you will see a field name like BirdDatabase.FieldTrips.Location where the pattern is DatabaseFileName.TableOrQueryName.FieldName.
    • If you have Field Shadings turned on the the View menu, the field names will appear with grey highlighting.
  3. Repeat as often as needed until you have the fields you need in your document.
  4. When you have set all the desired fields in the document, click after the last field you have added. Press the space bar once. (This makes it easier to see the Next Record field when Field Shadings is turned on.)
  5. Go to the Insert menu and choose Fields and then Other. The Fields window will open.
  6. Click on the Database tab
  7. Select Next Record in the Type section and click Insert You should now see a narrow grey field marker.
  8. Copy all the fields, including the Next Record field and any text you want to repeat for each record.
  9. Click after the Next Record field and paste. (Hit Return first if you want the next record to appear on a new line.)
  10. Repeat until you have as many sets of fields as you have records you want to appear.
  11. You can now select a range of records and click on the Data to Fields button as above, or choose File and Print to print your document, as above.

[edit] Quickly Inserting Fields

The downside of using the Next Record field is that you have to copy and paste the group of fields as many times as you have records. Here's an easier way.

  1. Open the Data Source View, select the database and then the query or table you want to use, as explained in the Intro to the Data Source View
  2. Filter and/or Sort your data as desired.
  3. Click and hold on the cell in the upper left hand corner of the data table; drag it into your Writer document. The Insert Database Columns window appears.
  4. Choose whether you want to add data as a Table, Fields, or Text and click on the appropriate radio button.
    • If you choose Fields or Text, you can include carriage returns and/or additional text between the various fields.
    Note that I got an "Expression is Faulty" error with some fields when using the Fields setting in the Insert Database Columns window. I did not see such an error with the Text setting using the same layout.
      • You can also specify a Paragraph Style.
    • If you choose Table, you can move all the fields over by clicking on the >> button.
      • To include column headings, check the Insert table heading checkbox. Apply column name will use the field names for the column headings. Create row only will create an empty first row in the table. Once the table is created, you can enter the column headings you desire.
      • You can select backgrounds and layouts by clicking on the Autoformat button and making your desired choices in the window that opens
      • You can specify table properties by clicking on the Properties button and adjusting settings in the Table Format window that opens.
  5. Once you have all the settings the way you want them, click OK
  6. Your table or text appears in the document.

[edit] Issues with Image Fields

Unfortunately, none of the approaches above will let you insert images from a database into your Writer documents. In order to use images from your database in Writer documents, you must use an image control in a form. Using forms in a Writer document is discussed below.

[edit] 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 Navigator button on the Form Design toolbar.
  3. Control-click or right click on the folder named Forms and choose New and then Form from the contextual menu.
  4. Control-click or right click on the newly created form (most likely Standard), and choose Properties.
  5. Click on the Data tab.
  6. Click on the ... next to Data Sources and browse to locate the desired data source
  7. Set the Content type for Table or Query, depending on your source. Those familiar with SQL can also choose SQL Command
  8. Select the desired Query or Table from the Content drop-down
  9. 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 the odb file do.

Note: Once a control has been drawn, you can also access the Form Properties window by clicking on a control to select it, and then clicking on the Form button on the Form Controls Toolbar.

[edit] Related Wiki Articles

Intro to the Data Source View
Filtering in the Data Source View
Sorting in the Data Source View


[edit] Related External Links

How to print more than one record on a sheet of paper in OpenOffice an article by Solveig Haugland


This article in other languages: Français
Personal tools