Advanced Adding and Combining of Fields

The AccuZIP6 5.0 Label and Report Designers allow you to place fields in any band of the template.  Because AccuZIP6 is written using the Microsoft Visual FoxPro programming language, fields can be added using that language and syntax.  There are many ways to add fields to your templates, but this topic will help you understand the functions and uses of the various methods.  First, you'll need to understand some field fundamentals to help with the template field creation process.  It is recommended that new users make use of the Label Layout Assistant to help create their templates.  If you want a template to do something specialized and can't quite figure out how to do it, please feel free to contact the AccuZIP6 Technical Support Department.

One of the biggest hurdles that new users (and sometimes even long time users!) have would be defining whether the field that they're adding is "character", "numeric", "date", or some other field type.  You could have a field that contains nothing but numbers, yet when you use a numeric expression, it gives you an error.  That's where this guide comes in.  When you understand how to identify the type of field you're printing, and how to combine it with other fields, template creation becomes incredibly simple.  Use this in conjunction with the Label Layout Assistant and the instructions found in the Page Layout and Page Setup and Creating a Title or Summary Band to create any type of label or report that you want.

Defining the Field Type
The first step for any user attempting to create a custom label is to determine the field types that he or she will be printing.  The steps to do this are extremely simple, yet critical.  To do so, you'll want to be looking at your database in the List View, and then follow the instructions below.

Table Designer Window with Character, Numeric, and Date types

As you may notice, most databases have many fields that list Character in the second column.  Character fields can contain letters, numbers, or symbols.  However, you'll also notice the "account" field listed in the Table Designer is identified as a Numeric field type.  Furthermore, the field "exp_date" is identified as a Date field.  These are the three most common field types that you'll print on a label or report, and each require different expressions to combine together.  If you're unsure of the field types that you'll be printing, or you get errors like "Invalid Function, Argument, Type, or Count", or "Data/Type Mismatch", you could be dealing with a situation where you are using the incorrect expression for the field types assigned.  If you run into issues like this and cannot identify the problem after reading through this topic, do not hesitate to contact the AccuZIP6 Technical Support department, where highly trained technicians can determine the cause of the problem.

Clearly identifying your field types and desired arrangement will make you a much more efficient list processor and printer, and the Table Designer can help you reach that goal.

Adding Character Fields to the Label or Report Template

For the next set of instructions, you will be operating from within the Label or Report Designer.  For instructions on how to enter the Label or Report Designer, see Creating a New Label Template and Opening Label and Report Templates.  Once you are inside of the Label or Report Designer, and you are clear on the field types that you'll be printing as identified using the preceding instructions in this topic, you're ready to continue.

Empty Report Expression Window

The critical area of the screen to the left is the "Expression" box.  Within this text box, you will place the syntax that will allow your template to print specific fields.  There are many ways to do this, and all are useful under different circumstances.  However, this guide will note the three core methods of adding fields to an expression:


 

Option 1: "az" method - The "az" method uses a set of variables created by AccuZIP6 5.0 programmers for the default fields found within the default field table.  If your database contains AccuZIP6 default names, then the "az" method will work perfectly, but takes a bit more work than the next option.  Between the fields, you'll need to either insert a comma or plus signs with quotation marks and a space between them to tell AccuZIP6 5.0 that you want to print a space between each field.  Examples of the "az" method would be:

 

 

azFirst+" "+azLast   or   azFirst,azLast
azAddress
azCity+" "+azSt+" "+azZip   
or   azCity,azSt,azZip

 

 

Option 2: "Field,Field" method - The "Field,Field" method allows you to combine any fields together on a single line, providing they are all character fields.  It will also work for a single field name by itself.  Some examples of "Field,Field" method expressions would be:

first,last
address
city,st,zip

Notice that there are no spaces between the field names, only a comma.  This method will also remove any extra spaces that would normally be present using the third option, without all the complicated expression syntax that it would normally require.

Option 3: "ALLTRIM" method - The "Alltrim" method allows you to use the three primary functions (ALLTRIM or ALLT for Character fields, STR for Numeric Fields, and DTOC for Date fields) in conjunction with plus signs to combine fields.  Between fields, you'll want to put any static text in between quotation marks to avoid the two fields printing right next to each other with no space separating them.  Examples of "Alltrim" method expressions would be:

ALLT(first)+" "+ALLT(last)    or    ALLT(first),ALLT(last)
ALLT(address)
ALLT(city)+" "+ALLT(st)+" "+ALLT(zip)    
or    ALLT(city),ALLT(st),ALLT(zip)

That's a lot of information to process, we know!  However, most users will find that the "Field,Field" method works most of the time for the standard list.  Simply create the Report Expression window using the steps provided at the beginning of this topic, and then fill in the Expression box with the field names that you want to print, separated by commas with no spaces.  In addition, if you simply added the fields together using the "az" or "Alltrim" method expressions, then the field in its entirety would be printed--not just the content inside.  In short, this means that if you had a name that was 10 characters long in a 50 character field, you'd have your 10 characters of information, followed by 40 empty spaces.  The "az", "Alltrim", and "Field,Field" methods all trim the fields to print just the content and leave out the leading and trailing spaces.


TIP!

Create one label line with the "Add Field" button .  Once you create the expression, click the OK button to return to the Label Designer.  The created line will still be active, indicated by the black dots on the corners, sides, top, and bottom.  You can now use the Windows shortcuts for Copy (CTRL+C) and Paste (CTRL+V) to duplicate the line.  Drag the newly created duplicate line into position by clicking and dragging the mouse button.  If the snap to grid option is on, and you find the box jumping around as you drag (and not moving smoothly), you can hold the CTRL key on your keyboard to temporarily disable the grid.  Once the new line is placed in the desired location, simply double click it to bring up the Report Expression window and modify the Expression directly.  This way you won't need to create and resize multiple lines--you can simply create one and then duplicate it with the exact height and width of the other lines!

Adding Numeric or Date Type Fields to the Expressions
Adding fields other than character fields requires slightly different syntax.  It's not any more difficult, you just have to keep in mind that numeric and date type fields must first be converted to a character string to print with other character fields.  Those expressions to convert numeric and date type fields to character strings follow:

Numeric Fields - ALLT(STR(fieldname))
This converts the numeric field to a character string, and then uses the "Alltrim" expression to remove any leading or trailing spaces, printing only the numerals.

Date Fields - DTOC(fieldname)
This converts a date field to a character expression...literally translated, it would be "
Date TO Character".

Using the previous example in the Table Designer, if you wanted to create a single label line with Company (Character), Account (Numeric), and exp_date (date), then you'd need to use the following expression.  We'll use the "Alltrim" method with the conversion strings as well:

ALLT(company),ALLT(STR(account)),DTOC(exp_date)

That will print the company, a space, the account, another space, and then the expiration date fields.

Advanced Expressions to Add Static Text
For the last expression modification to be found within the user's guide, we'll deal with adding something
other than a space between fields.  We'll stick to the previous example, but if you wanted to add "Customer #" before the account number, and "Expiring" prior to the expiration date, you'd want to use plus signs with quotes instead of the commas separating the fields.  You'll want to put the exact text, including spaces, between the quotes, which are in turn between the plus signs.  To make it sound even more complicated, those plus signs are between the fields and the functions.  It sounds tricky, but it's not when you really look at it.

"Functions" usually have parentheses around a field name.  These functions trim a character field, or convert numeric fields or date fields.  They can also be used to print portions of fields, among other advanced features.  Any time you are printing a field with a method other than the "az" method, you'll be adding a function of some sort to the field name.  Whether it's an ALLTRIM, the "az" variable found within the default fields, or some other expression, you'll be using functions to trim the field down or otherwise streamline its appearance.

Between those functions and fields, you'll have a plus sign, indicating that you're joining the field with something else.  If you're joining it with a space, you'd have quote-space-quote to tell it to print whatever is between the quotes--in this example, a space.  Since we want it to print "Company #" between the quotes, we type exactly that, with a space before the word "Company" so it doesn't print right next to the company name field:

ALLT(company)+" Company #"+ALLT(STR(account))

It's that simple!  To complete the guide's instruction, we'll add the final "Expiring" message--again, with a space after the word to avoid printing it directly next to the date.  The entire expression, when completed, will read:

ALLT(company)+" Company #"+ALLT(STR(account))+" Expiring "+DTOC(exp_date)

That would print a line that looked like this (company is in red, static text is in black, account is in green, and the exp_date field is in blue).

ABC Plumbing, Inc. Company #12345 Expiring 07/31/2007

Again, some of this is using intermediate to advanced Visual FoxPro syntax for the label expressions, so if you're having trouble understanding it, feel free to contact the AccuZIP6 Technical Support Department, or review the usage of the Label Layout Assistant.