Solved

Spacing fields while concatenating in a Cyrstal Formula

Posted on 2004-10-19
7
382 Views
Last Modified: 2010-05-18
I'm using the following formula to concatenate some fields:

DateValue ({totals.applydate}) & " " &
{totals.personnum} & " " &
{totals.accountname} & " " &
{totals.accountdsc} & " " &

The size of the accountname and accountdsc fields vary but I want the fields to line up in the report.

How can I make the accountname and accountdsc fields be always 25 characters, left justify with spaces?

I tried left({total.accountname},25) but it didn't work.

I'm Crystal Version 8.5 SP3

Thanks
0
Comment
Question by:kronoscanada
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 65 total points
ID: 12347393
try using where there are 25 spaces ' '

left({total.accountname} & '                               ',25)

mlmcc
0
 
LVL 28

Expert Comment

by:bdreed35
ID: 12347447
Is there a reason you are concatenating the fields together?  You can get the fields to line up just by placing each individual field in the details section.

If you need to concatenate them, we can write a formula to accomodate this, just keep in mind that you will need to change the font to a fixed width font like Courier New.

DateValue ({totals.applydate}) & " " &
{totals.personnum} & " " &
{totals.accountname} & " " &
{totals.accountdsc} & ReplicateString (space(1), 25-length({totals.accountname})-length({totals.accountdsc} )) & " " &

I left the last "&" because I assumed there was more to the formula based upon what you said in your post.
0
 
LVL 28

Expert Comment

by:bdreed35
ID: 12347488
mlmcc's method will work good too, in fact I think I like it better than the replicate string function that I used.  
The only modification I would make is to use the space function instead of trying to hit the spacebar 25 times:

left({total.accountname} & space(25),25)
0
Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

 

Author Comment

by:kronoscanada
ID: 12347749
Almost there, I tried:

DateValue ({totals.applydate}) & " " &
{totals.personnum} & " " &
left({totals.accountname} & '          ',10) &
left({totals.accountdsc} & '          ',10)

I'm using 10 instead of 25 just for testing and for this question.

The output looks like this:

10/11/2004 10001 12345   Toys
10/13/2004 10001 123456789 Kitchen

Line one does not have 5 spaces after the accoutname (12345). Line two looks good.
0
 
LVL 28

Accepted Solution

by:
bdreed35 earned 60 total points
ID: 12347788
Are you using a fixed width font like Courier New?  A non fixed width font could keep them from lining up.

Also, use the space function to ensure you have 10 spaces:

DateValue ({totals.applydate}) & " " &
{totals.personnum} & " " &
left({totals.accountname} & space(10),10) &
left({totals.accountdsc} & space(10),10)
0
 

Author Comment

by:kronoscanada
ID: 12347993
Wow, you guys are fast! and good!

I'm using:

DateValue ({totals.applydate}) & " " &
{totals.personnum} & " " &
left({totals.accountname} & space(10),10) &
left({totals.accountdsc} & space(10),10)

With Courier New (Western) and it works!

I'm new to this site but it looks like mlmmc and bdreed35 should split the points, 75 each. I need to figure out how to do that.

I thought someone would ask why I'm concatenating in the first place.  I put these fields in a Cross Tab and the row labels would not repeat if there where the same, so I concatenated the fields and now every row is unique.



0
 
LVL 101

Expert Comment

by:mlmcc
ID: 12354146
Glad i could help

mlmcc
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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