[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Subreport Location Needs to change as other objects grow

Posted on 2008-11-08
Medium Priority
Last Modified: 2012-08-13
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?
Question by:kahuna59
  • 2

Accepted Solution

Cootser earned 1000 total points
ID: 22914001

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

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

shared stringvar 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

shared stringvar 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


Author Closing Comment

ID: 31514717
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.  

Expert Comment

ID: 22916136
Glad to help, best of luck in the future.

Its good to give something back to EE....

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month20 days, 3 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question