Solved

Spacing fields while concatenating in a Cyrstal Formula

Posted on 2004-10-19
7
356 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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. …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
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…

708 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