Subreport Location Needs to change as other objects grow

Posted on 2008-11-08
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
    LVL 3

    Accepted Solution


    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

    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.  
    LVL 3

    Expert Comment

    Glad to help, best of luck in the future.

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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
    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 …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now