Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: zero fill Post Reply Post New Topic
Author Message
TorLang
Groupie
Groupie


Joined: 13 Jun 2012
Location: United States
Online Status: Offline
Posts: 50
Quote TorLang Replybullet Topic: zero fill
    Posted: 24 May 2016 at 1:45am
Has anyone figured out how to zero fill field using a custom formula where the field has to be a certain length, zero filled to that length, if the field value is shorter?

I would think the custom field would look different depending on if its a numeric or a text field.

for example:

field value : 345 (numeric)
fixed length: 7
right justified

will have to look like this:

0000345

field value: 34523

will have to look like this:

0034523



IP IP Logged
Valert16
Groupie
Groupie
Avatar

Joined: 21 Mar 2016
Location: Spain
Online Status: Offline
Posts: 57
Quote Valert16 Replybullet Posted: 26 May 2016 at 12:48am
For example:
ToText(345, "0000000") returns "0000345"
ToText(34523, "0000000") returns "0034523"

Take a look at CR help, paragraph "Format Strings"
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 02 Jun 2016 at 8:07am
replace(right(space(x) + totext({field}, x), x)," ", "0")

as another idea...
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.030 seconds.