Solved

Spacing fields while concatenating in a Cyrstal Formula

Posted on 2004-10-19
7
360 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 100

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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 100

Expert Comment

by:mlmcc
ID: 12354146
Glad i could help

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Crystal Reports - Page Break by Line count 7 54
Crystal Reports Sub Report 4 78
Speed Up Crystal Report 5 47
Pagination Difference  in crystal report 7 42
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. …
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 …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

18 Experts available now in Live!

Get 1:1 Help Now