• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

Subreport Location Needs to change as other objects grow

I am using Crystal Reports in Mas200 for a form that prints a customers address.  Mas200 won't link the country code table to the Sales Order table if the CC is only two characters (wants 3) so the work around (which works) is to create a Crystal Subreport consisting of the countries and linked to the main report via the country code field. The Subreport is merely the country name based on the linked CC.  The problem is, the rest of the customer address is in a text field in the main report that grows depending on the number of lines in the address and therefore the location of the Subreport (country name) needs to move up or down as the number of address lines changes.  It appears the subreport cannot be added to a text field like other fields can or be used in any formula field.  How can I make this country field print at the bottom of my address block regardless of size?
0
kahuna59
Asked:
kahuna59
  • 2
1 Solution
 
CootserCommented:
Hello

Could you try using a shared variable in the subreport to pass the country name back into the main report?

For example, create a formula in the subreport called Country.  The formula syntax would be

whileprintingrecords;
shared stringvar Country := {table.fieldname} // this field is the country name

Place that formula in the Report footer of the subreport

In the main report place the subreport in a section above the section where the address is to be displayed

The in the main report create another formula called Address

It might look like this

whileprintingrecords;
shared stringvar Country;
{table.Addressline1}+Country

In this formula the main report address lines are concatenated with the Country value as passed from the subreport to the main report

When concatenating address lines you might need to add in a carriage return / line feed

For example

whileprintingrecords;
shared stringvar Country;
{table.Addressline1}+chr(10)+chr(13)+Country

(I have to say that i dont have crystal installed on this PC so i may have the wrong values for +chr(10)+chr(13))

The shared stringvar Country must match case in both sub and main reports

I hope this helps a bit

Best regards

Cootser
0
 
kahuna59Author Commented:
That pretty much did it.  Final details are, in order to keep the formula field from the subreport footer from printing where the subreport was inserted into the main report (Report Header above the Page Header) I had to suppress the formual field in the subreport.  It did not work to suppress the subreport section or the main report section, or the subreport in the main report section because the Shared variable value would not pass.  FYI, you remembered chr(13) and chr(10) correctly.  My address formula was already assembled with variable declarations and value setting with carriage returns so all I had to do was add one more declaration for the shared variable and it was good to go.
Thanks for the help.  
0
 
CootserCommented:
Glad to help, best of luck in the future.

Its good to give something back to EE....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now