Solved

Spacing fields while concatenating in a Cyrstal Formula

Posted on 2004-10-19
7
380 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
[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

 

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

729 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