How to Edit a Combined Script Field in an Existing Report Template

Top  Previous  Next

As with any tutorial it is always recommended to read through the tutorial first, and then perform the steps of the tutorial.

 

 

In this tutorial we will go through the steps to customize the sample AVERY 5160 Address Label report template field XRLabelX that is presently using a script to display the Title, First Name and Last Name in one field.

 

First we will customize this script to not include the Title in the combined script.

 

Then we will customize the script to again include the Title

 

It is recommended that you  review the Report Designer Features topic and previous report template tutorials before proceeding if you have not yet done so

 

1.In Addressinator!, click on the menu item File, then click on Report Designer

 

2.This will open up the Report Designer screen

 

3.Select menu File -> Open and select to open up the report template AVERY 5160 Address label

ReportDesignerOpen1

 

4.Click on the Preview so we can see what the report template looks like before we make our changes

 

a.Note that contacts that have a title (Mr. Dr. etc) show that title in the print preview

 

5.Select Designer

reportdesignerDesigner

 

6.click on the field xrLabel2 in the design panel (has Text combined title firstname lastname)

 

a.by clicking on the field, you identify to the report designer this is the field you are working with)

reportscript1

 

7.If not already showing, select the Properties tab on the left

 

8.Expand the Scripts property

reportscript2

 

9.Select the OnBeforePrint script property to view the Script Editor for this OnBeforePrint script property

reportscript3

 

reportscript4

 

a.An OnBeforePrint script "runs" before printing - and is a way of perfoming something that normally the report designer can not do on its on
b.for example, we could instead have placed the three datafields ATITLE,  AFIRSTNAME and ALASTNAME onto the design panel, but than if a contact has a really short name, there would be a huge space between the first name and the last name. Using the script makes sure there is no more than one space between the title, first name and last name.

 

10.We are now going to edit the OnBeforePrint script so that the title does NOT print at all.

 

a.The script originally says

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)

{

xrLabel2.Text = string.Format("{0} {1} {2}", GetCurrentColumnValue("ATITLE"), GetCurrentColumnValue("AFIRSTNAME"), GetCurrentColumnValue("ALASTNAME"));

}

b.Delete the following from the script

 

{2} and the GetCurrentColumnValue("ATITLE"),

 

c.Now the script line will now say instead

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)

{

xrLabel2.Text = string.Format("{0} {1}", GetCurrentColumnValue("AFIRSTNAME"), GetCurrentColumnValue("ALASTNAME"));

}

 

d.Select OK to close the OnBeforePrint script
e.Click on the Preview
f.Note that the contacts no longer display the title as they previously did

 

11.Now we will edit the OnBeforePrint script so that the title will print if the contact has one.

 

a.Open the OnBeforePrint for the field xrlabel2 again
b.Add the following text back into the script

{2} and the GetCurrentColumnValue("ATITLE"),

 

c.The script will now display as the following

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)

{

xrLabel2.Text = string.Format("{0} {1} {2}", GetCurrentColumnValue("ATITLE"), GetCurrentColumnValue("AFIRSTNAME"), GetCurrentColumnValue("ALASTNAME"));

}

 

d.Select OK to close the OnBeforePrint script
e.Click on Preview
f.Note that the title is now displaying again.

 

12. Select File -> Exit

 

13. It will ask Close without saving? - click on Yes so that all changes we made are NOT saved, and the report template reverts back to its original state before we made any changes.