How to fit address fields correctly in a Windows Envelope

Summer is over and Directions EMEA is only 9 days away. I have a Reporting Tips and Tricks session at Directions so if you are there I expect you to join my session :-).

This year Abakion will also sponsor Directions EMEA. We have never done that in past so this is real exiting. We will show case our Supply Chain Box product, so be sure to stop by our booth. You can also read much about Supply Chain Box here:

image 

OK, enough marketing lets get down to business, and let’s face it, you are reading this blog post because you want Reporting tips and tricks :-). So how do we actually consitently place the address fields, so they fit perfectly in the small windows of a Windows Envelope. By now many of you have worked on Document reports and have struggeled with this. In the begining I felt like I was designing my reports in water, because everytime I placed the address fields the moved around, until I understood how our lovely Visual Studio Report designer was working.

To find the right location we need to consider the following things:

  1. Code.SetData textboxes
  2. Creating a retangle around the address fields
  3. Top Margin
  4. Left Margin
  5. A report which have the address fields place correctly

Code.SetData textboxes

First you might wonder why we need to look at the Code.SetData textbox. Well the reason is that this or these text boxes will influence the location of the Address fields. Let me show you.

Here I have sample document report with the address fields perfectly fitted for the Windows Envelope

Designer:

image

Print:

image

I have emmbedde a background image, which shows me exactly where the window on the Windows Envelope will be. Notice that the backround image of the Report will not show in the Margins. No something I will go into now, but now you know if you did not already of course.

Now let me add a Code.SetData text which we have on all our document reports. For demostration purpose I have increased the size of the Code.SetData textbox and marked it red. Now let see what happens when I print the report:

Designer:

image

Print:

image

As you see “funny” things start happening, and it looks like the Code.SetData textbox completely deletes the section where it is placed and then pulls the address fields up the report, exactly of height of the Code.SetData textbox. In some sceanrios that could actually be handy, by here it is just a pain.

So how do we fix this. Well in the first place it is broken that the value has to go to the Visibility expression. Hidden expression in Report headers are rendered as the last thing in  Report Viewer 2010(NAV 2013) so tricking the Report Viewer to render the expression as the first thing by moving it to the Visibilty expression is just wrong. And we see above that this is not something the Visual Studio ever tested or they newer thought we we would work with it like this.To fix this we copy the Value from the "Show or Hide based on a expression" and set Visibilty to "Show". Paste the value into normal expression on the General tab, and then set the font to white in the Font tab. This way the the textbox will be visible, but "TRUE" value will be hidden because font is the same color as the paper. For demo purpose I keep the Code.SetData textbox red so you can see that I have a value in textbox. You of course mark the textbox white.

Designer:

image

Print:

image

First problem solved

Creating a retangle around the address fields

Usually customers don’t like the address fields of font size 8pt which the UX-Guidelines tells us to do. 8pt is just to small for Postman Pat to read. So we increase the font to 10pt. Now the we increase the size of the Address Textboxes to 13pt. 12pt is no good, because it will truncate the bottom of the letters “g”. “j” and “y”. With this excersize you now have textboxes on left side of the report of size 13pt and on the right side of the size 10pt or hopefully 11pt, because 10pt will again truncate the bottom of the letters “g”. “j” and “y”. When you do this Visual Studio has an easter egg built in, so it moves the textboxes on left and right side around and when printed they are not placed in the right places. This is just a pain and to resolved this issue we place a rectangle around the address fields on the left side. Sometimes this does not completely fix thes issue, if not, you place a rectangle around the textboxes on the right side as well.

Second problem solved

 

Top Margin and Left Margin

Now finnally we can get down to placing the address fields at the correct position in our report. So for us to place the address fields correctly we need to note down the values in the in the Top Margin and Left Margin in Report properties. In my example I’m using the lovely margins in report 116 – Statement in the Danish version:

Top margin = 1,05834cm

Left Margin = 1,76388cm

These values is all I need from this report.

A report which have the address fields place correctly

Now I need the values from a report which I have verified prints the address fields correctly. And the I place all these values in this spreadsheet:

image

You could of course argue that I do not need this spreadsheet, because I could just set the Margins to the same size in the report that I’m fixing, but I’m considerng that as major changes and could easily give me extra work fixing the whole report to fit correctly to the new margins.

After you have inserted the correct 4 values on left side and inserted Left and Top Margins on the right side for the report you are fixing, you now have the values for the Location properties Left and Top. So go back to Visual Studio and paste these values in for the Rectangle you created around the Address field in above step 2. Notice that the Textboxes does not follow along with the rectangle when you do this. This is another easter egg in Visual Studio. To fix this move the top Address textbox to the top left corner of the Rectangle, do not use the mouse for this excersize. And then left align below Address textboxes to the this textbox and then remove vertical spaces. Tip! Using the buttons in Layout toolbar you can do this in under 5 seconds, so if you are spending more time on this aligment, you are doing it wring. The Layout Toolbar is my best friend in Visual Studio.

The above spreadsheet I am using can be found here along with the background image for C5 Window Envelopes. This background image only works if the margin is to Left=2cm and Top=1cm, so use the spreadsheet to get the correct values for your report. http://sdrv.ms/155VRjV

/Thanks, Claus Lundstrøm, Abakion.com & Supplychainbox.com

Advertisements