Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Setting static field length Post Reply Post New Topic
Author Message
stcyrk
Newbie
Newbie


Joined: 28 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote stcyrk Replybullet Topic: Setting static field length
     Posted: 28 Jul 2010 at 5:48am
I am trying to be able to set a fixed length for a field.  For example, querying a table, one of the fields returned can be a little as 2 characters, up to 10 characters.  I want the field length to always be 20 characters long, with spaces following data.  E.G. (123abc              )
I haven't found a formula to achieve this and any help would be greatly appreciated.  On XI.
K. StCyr
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Jul 2010 at 6:41am
left(field + "                    ",20)
IP IP Logged
stcyrk
Newbie
Newbie


Joined: 28 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote stcyrk Replybullet Posted: 28 Jul 2010 at 7:18am
Thanks for the quick response.  However, checking syntax, I receive an error on the "    " segment.  It's looking for a number, currency amount, date, date/time.  here's what I tried:
Left ({CBCHECK.SERIAL-NUM} + "     ",20 ) where cbcheck.serial-num is the database field.
K. StCyr
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Jul 2010 at 7:34am
I aasumed CBCHECK.SERIAL-NUM was a string but it sounds like it is numeric.
If that is the case try:
Left (totext({CBCHECK.SERIAL-NUM},0,"") + "     ",20 )


Edited by DBlank - 28 Jul 2010 at 7:43am
IP IP Logged
stcyrk
Newbie
Newbie


Joined: 28 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote stcyrk Replybullet Posted: 28 Jul 2010 at 7:47am
That worked, thanks.  However, that formula assumes the database field is constant, e.g. 3 characters long.  Therefore, If I put 3 spaces in between the quotes, my field is 6 characters, regardless of the last variable, 20.
K. StCyr
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Jul 2010 at 7:52am

Sorry I copied from your reply and it had too few spaces.

It is suppose to have 20 spaces between the quotes so that it does not matter how long of a string serial num is.
 
Left (totext({CBCHECK.SERIAL-NUM},0,"") + "                    ",20 )


Edited by DBlank - 28 Jul 2010 at 7:53am
IP IP Logged
stcyrk
Newbie
Newbie


Joined: 28 Jul 2010
Location: United States
Online Status: Offline
Posts: 7
Quote stcyrk Replybullet Posted: 28 Jul 2010 at 8:14am
Ahhh, gotcha.  Thanks very much, that worked perfectly.
K. StCyr
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum