Word Reports

The "Word Reports" feature is available only in Pedigree Cloud and allows a Microsoft Word document to be filled in with data from your database. With Word Reports there are no limits to the kinds of Word documents you can create from Show Catalogs,Registration Certificates, Pedigrees, Health Records, etc. The only limit is your imagination. You can create a Word Report for any purpose you can think of.

Word Reports comes with three standard templates which you can use or modify for your purposes or you can convert one of your existing Word documents into a template.

In the following sections we describe how to create a template document and then look at each of the supplied templates to see how it works

Menu Commands

In this section we look at the three menu commands available for Word Reports and what those commands do. They are as follows:

  • TOOLS-Merge Word document-Current selection. This will use data from the current selection to fill in the Word document. What happens next is that a file open dialog will appear. Select the Word template file and click OK. The template will be copied to a file with the name of the current record and the various fields will be filled in.
  • TOOLS-Merge Word document-Marked records into a single file. This will do the same as above but instead of creating a filled in document with data from the currently selected record, it will create a single filled in document but with the entire contents of the template duplicated for each record. This command is useful for creating show catalogues
  • TOOLS-Merge Word document-Marked records into separate files. This will do the same as above but instead of creating a filled in document with data from the currently selected record, it will create a filled in document for every record that is marked with the primary mark color. The entire contents of the template are duplicated for each record. This command is useful for creating multiple files one per marked record, e.g. if you have many registration certificates to create.

The Basics

The simplest document template is as follows:

{subject=0;t=pedigree}{f=name;r=0}

The above template for example will create a Word document with just the name of the subject. To do that, first double click on the record in the "Edit All Records" tab or "grid view" - this makes that record the "current selection". The record will then appear in probably a 4G pedigree form. The actual form is irrelevant because the next step is to use the TOOLS-Merge Word document-Current selection menu command. A File Open dialog will appear. Select the Word template file by double clicking it. A few seconds later a copy of that template file will open up in Word with the tags replaced with data.

This simple template consists of two tags. All tags are wrapped in curly braces (we will refer to them as just braces). A command consists of multiple parameters separated by semi-colons where each parameter is of the form “parameter name=value”. The first parameter is special because it always specifies the type of tag. So above we have a “subject” tag and an “f” tag.

As you can see the braces are treated as special characters. If you actually want to include braces as normal characters and not as indicating the start of a tag, then use two together.

Let’s break these two tags down. The first tag is “{subject=0;t=pedigree}“ The first parameter is “subject=0”. The first parameter’s name can only be one of three values:

  • Subject – this makes this tag the one and only subject of this form. The currently selected record will be assigned to the subject. The value of the subject is just a string which can be anything but we decided to just make it a number. BTW a subject is also a record like the tag listed next. The only difference is it is the “root” or starting record and there can be only one of them.
  • R or record – these are for records. All records must be linked to a parent record or to the subject which of course is also a record.
  • F or field – these are for fields. A field refers to a particular field in a record, e.g. Name, Sex, DOB, Sire, Dam.
  • E – this is an expression and is an alternative to a field.

So based on the above the {subject=0;t=pedigree} says the subject record (from which ALL other records derive) is called "0" - the actual name is irrelevant its just a "handle" for other tags to refer to. The "t" or "table" parameter has a value of "pedigree" and therefore the subject must be in the pedigree table, because that's how the form is designed. If we wanted to do a "litter report" the subject tag would set "t=litters".

The "{f=name;r=0}" tag references the subject record because it has "r=0". The "0" is not important - its just a name and you can use any name. The "f=name" means that the name field should be looked up in the subject record and its value used to replace the tag. So that's it - the World's simplest Word Report. In the next section we will go into more detail on the tag definitions.

Tag Definitions

Subject

The subject tag only has a “t” parameter which specifies the table in the database that this applies to. It must match the current record selected in the main grid view. Let’s say you are trying to fill in a pedigree document but your current table is the “Show” table then it will complain.

Record

Here are the allowed parameters in the "r" tag:

  • The “r” parameter always comes first because that's what declares this tag as being a record tag. A simple example is: {r=some name;...}. The name is optional but it must be unique. If it is not specified – example {r;...} – then no other record or field can refer to it. This can only work if the "f" parameter is also used in this tag - see below for details.
  • The “p” parameter which specifies the name of its parent record.
  • The “pf” or parent field specifies the name of the field to use to look up in the parent record. A classic example is in a pedigree where let’s say the subject is {subject=main;t=pedigree}, then you might want to have a record for the subject’s Dam, then this would look like {record=22;p=main;pf=Dam;t=pedigree}. What it is doing here is getting the database record set on the subject, getting its “Dam” field and then looking in the pedigree table for a record where the name matches.
  • The "f" parameter is optional and is a shortcut instead of having to create a separate "f" tag. The shortcut avoids the need for having to specify a separate "f" tag and having the "r" parameter match. As an example, instead of {r=mainsire;t=pedigree;p=main;pf=sire}{f=name;r=mainsire}, we can replace it with just a single tag: {r=mainsire;t=pedigree;p=main;pf=sire;f=name}. If there are no other records or fields that reference this tag then we can dispense with the name so we have: {r;t=pedigree;p=main;pf=sire;f=name}. This is often useful in the last generation of a pedigree.

Field

A Field tag displays the text from a field in a record. It always looks like {f=name of a field;r=name of a record}.

The “r” parameter which will have a value that matches a record name. It will also have an “f” parameter which is the name of a field in that record. So “{f=DOB;r=main} will display in its place the contents of the DOB field of the record.

The f parameter can also refer to the name of an expression. Note that when naming an expression it must have a unique name and not be the same as any field in the tables used in this form. Expressions are discussed in the next section.

Expression

An expression is used to specify a combination of fields. It’s a useful shortcut. The form of the tag is {e=some name;f=field1, field2, field3 ...}. So now whenever an "f" tag is specified, instead of using a field name you can use the name of an expression. As an example we could use {e=nameplus;f=pretitle,name,posttitle} to replace "{f=pretitle;r=main} {f=name;r=main} {f=posttitle;r=main}" with just "{f=nameplus;r=main}". Note the name of the expression can be anything BUT make sure its not the name of an actual field.

Sample Templates

Registration Certificate

In this section we will use what we learned above to understand a simple registration certificate. The screenshot below shows the template Word document.

The Word Reports feature is "multi pass" which in simple terms means that the order in which you place tags doesn't matter. You could define a field tag before the record tag it references. This is what has happened in our sample code. The first line is {f=pretitle;r=0} {f=name;r=0"} {f=posttitle;r=0". It is referencing a record called "0" that isn't defined until the next line.

The second line is the "subject" tag. It simply names the subject record "0" and says it exists in the "pedigree" table. One and only one subject record is always required.

All the other tags in this document are all field tags, e.g. {f=color;r=0}. They all reference the subject record called "0" and the "f" parameter value is just the name of the field to show from the subject record. The result of using the TOOLS-Merge Word document-Current selection command for one sample record is shown below.

Simple 2 Generation Pedigree

We are showing a simple 2 generation pedigree to make it easier to understand template design. The template for this is shown below.

The document template begins with the usual subject tag, but after it, is an "expression" tag, {e=nameplus;f=pretitle, name, posttitle}. This will be replaced with the value of those fields in order and separated by a space.

The header for the pedigree then uses the expression defined above: {f=nameplus;r=subject} in the title, then in the following lines it has some labels as plain text followed by tags to display the values of those fields in the subject record.

The previous steps were pretty easy but in this step we will show information from the sire and dam records by adding more "r" tags. First up we need to create a record for sire and dam and have it linked to the subject record. Because there are a lot of records in a many generation pedigree we use simple names. For the sire record we use the name "s". We set the parent of the sire record to be the "subject" and specify the table the sire record resides in as the pedigree table. The "pf" parameter says that we should get the value of "sire" field from the "subject" record then use it to look up a record in the pedigree table with the same name. We do the same for the dam record but we give it the name "d" and set "pf" to "dam".

Below those records we have some field tags that reference the sire or dam record and specify what field to show from the record.

For the second record we name the sire's, sire "ss", set its parent "p" to "s" and "pf" to sire. In other words we say create a record by looking at the value of the sire field in the "s" record then look in the pedigree table for a record with that name. We proceed in this fashion for the rest of the second generation giving record names based on their position in the pedigree, e.g the dam's sire is named "ds". Sample output from running this is shown below.

Show Catalog

This example is quite different from the previous one because we will be doing it for multiple subjects. This is accomplished by marking all the records you want to appear in the catalog then using the TOOLS-Merge Word document-Marked records into a single file command. The sample Word template document is show below. All the content in the template document is repeated then filled in for each marked record.

The template starts with the usual subject record: {SUBJECT=0;T=PEDIGREE}. Then follows with an expression definition which we use to simplify later tags: {E=NAMEPLUS;F=PRETITLE,NAME,POSTTITLE}. We then have a field tag to display the name and titles of the subject: {F=NAMEPLUS;R=0}, then the sex in parens and registration. Note commands and names are not case sensitive.

The breeder and owner are simple field tags referencing the subject record called "0".

For the sire and dam we have to create a record for each. The sire record tag is: {r=1;pf=sire;p=0;t=pedigree} so its named "1", the field to lookup is "pf=sire" in the parent record is "p=0". In other words the record for the sire is calculated by looking in the parent record at the sire field and looking for a record in the pedigree table with that name.

We do something similar for the dam record. Obviously giving it a unique name "4" and setting "pf=dam" so it looks at the dam field.

For both the sire and dam we need to lookup their sire and dam, so in the case of the sire we have {r=2;pf=sire;p=1;t=pedigree} which is a record called "2" that looks in the sire field of the sire record "1" and finds the record with the matching name in the pedigree table.

A short screenshot of the output is shown below. Normally you would copy and paste this in to the master show catalog document.