Print Page | Close Window

subreport caption

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16857
Printed Date: 06 May 2024 at 2:46pm


Topic: subreport caption
Posted By: lyman
Subject: subreport caption
Date Posted: 26 Jun 2012 at 7:20am
I have an on-depand subreport - which is working fine - but the caption for that subreport is the staff member's name, the date of the report, and the originator.  Is there any way for that caption to be displayed in columns.
 
Currently:
Lin Moss   1/1/2012   Susie Queue
Stanley Stanaslowski   6/15/2012   Michael Lasdforal
 
I would like the columns to line up for easier reading.  Working in Crystal X



Replies:
Posted By: kevlray
Date Posted: 26 Jun 2012 at 7:38am
Are they separate fields in the sub report?  If so you should be able to position them on the page where you want them.  If not you might be able to separate out the date into three different 'fields' with formulas.


Posted By: lyman
Date Posted: 27 Jun 2012 at 10:43am
I can put the fields on the page, supress the sub-report and layer that sub-report on top of the fields but that creates another issue.  A user who clicks on the fields themselves will not bring up the sub-report, they have click on a 'space' either between the fields or in front of the first field or in back on the last field to bring up that sub-report.  I'm guessing that's why the 'on demand subreport caption' was used but it's not easily readable.  I added a box on the detail line to simulate a checkbox and if the user clicks on it, the sub-report comes up but I like another method so that they could click anywhere on the line and have the sub-report would come up.


Posted By: kevlray
Date Posted: 27 Jun 2012 at 11:55am
I missed the part about it being a on-demand sub-report.  I would think (but have not tried) that the layering would work.  It is something I would have to experiment with.


Posted By: kevlray
Date Posted: 27 Jun 2012 at 1:28pm
I looked into the subreport on demand.  Yes it could be done, but a lot of string manipulation will need to be done.  Basically it will have to be determined the longest length for the names and then pad the names with spaces that are shorter than the longest name.  Then put it all together as one one fixed length string.

I will see if I have time to work out an example tomorrow.


Posted By: kevlray
Date Posted: 29 Jun 2012 at 9:00am
I finally got some time to work up some code.  This code assumes 20 characters max for a name and eight characters max for the date.  It is easy enough to add spaces.

{Name}+space(20-len(trim({Name})))+totext({Date})+space(8-len(trim({Date})))+{Name2}+space(20-len(trim({Name2})))


Posted By: lyman
Date Posted: 03 Jul 2012 at 4:46am
The columns are not lined up, I think the TRIM function isn't working on the date, since the number of spaces that the columns move correspond with the number of characters in the date.  This is what I added.  I'm trying to fill the whole line.
 
SPACE(41)+ToText({date})+space(25-length(Trim(ToText({date}))))+
{user_name}+space(34-len(trim({user_name})))+{originator_value}+space(30-len(trim({originator_value})))


Posted By: kevlray
Date Posted: 05 Jul 2012 at 12:14pm
You may need to use the optional parameters for the totext (it depends on the data type).  I do not remember the option for a date field.


Posted By: lyman
Date Posted: 06 Jul 2012 at 7:48am

Adding the extra parameter to the date field helped; the Date and User_Name align in columns but the originator_value field is still shifting on the page with the number of characters in the User_Name. 

 

SPACE(41)+ToText({date},"MM/dd/yyyy")+

space(25-len(Trim(ToText({date},"MM/dd/yyyy"))))+

{user_name}+space(34-len(Trim({user_name})))+

{originator_value}+space(30-len(Trim({originator_value})))



Posted By: kevlray
Date Posted: 06 Jul 2012 at 8:23am
Strange, it shouldn't (provided the user_name is less than 35 characters long).


Posted By: lyman
Date Posted: 11 Jul 2012 at 8:49am
Solved!  The problem was the font.  Once it was changed to a non-proportional, the caption came up in the correct alignment. 
 
Smile



Print Page | Close Window