Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Zero-fill Field in CR2008 Post Reply Post New Topic
Author Message
pittla1
Newbie
Newbie


Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
Quote pittla1 Replybullet Topic: Zero-fill Field in CR2008
    Posted: 28 May 2009 at 10:32am
Hello all!  I am trying to zero-fill a field and am not having much luck.  Basically, I have a check number field that is 5 to 8 characters long and it need to zero-fill to 10 characters (i.e. 12345 needs to be 0000012345).  I have tried doing ToText(<field>, "000000000"), but I get an error saying too many arguments.  Any suggestions you might have would be greatly appreciated!  Thanks!
IP IP Logged
axelcore
Newbie
Newbie


Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 3
Quote axelcore Replybullet Posted: 28 May 2009 at 11:13am
I am having the same issue.  I need to have 11 total digits regardless of the amount of the check.  So if it is $12 it should read as 00000001200.  Any help with this problem is greatly appreciated.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 May 2009 at 11:23am
Pittla-
assuming it is a numeric field:
Right(("00000" + totext({table.field},0,"")),10)
 
Axelcore-
What if it is $12.13? Would it be "00000001213"? or will it always be 00 on the end?
IP IP Logged
axelcore
Newbie
Newbie


Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 3
Quote axelcore Replybullet Posted: 28 May 2009 at 11:24am
Yes if it is $12.13 it would be 00000001213
IP IP Logged
pittla1
Newbie
Newbie


Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
Quote pittla1 Replybullet Posted: 28 May 2009 at 11:41am

Thanks DBlank!  That did work after I converted the field to numeric.  The field was not originally numeric which is probably why my ToText formula was bombing.  Thanks again for your help!

IP IP Logged
pittla1
Newbie
Newbie


Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
Quote pittla1 Replybullet Posted: 28 May 2009 at 11:52am
Hi axelcore!  I actually needed the check amount too and I was able to get the formula DBlank gave me above to work by creating another formula field.  This probably isn't the best way, but it worked!
 
create @chkamt field (check amount * 100) then plug in the @chkamt field to another field, say @formatchkamt
Right(("00000" + totext({@chkamt},0,"")),12)
 
Hope this helps!
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 May 2009 at 12:23pm

axelcore , just in case here is how i would do pittla's suggestion for your circumstances:

Right(("0000000000" + totext(({table.amount}*100),0,"")),11)
IP IP Logged
pittla1
Newbie
Newbie


Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
Quote pittla1 Replybullet Posted: 28 May 2009 at 12:47pm
LOL ya that works much better.  I don't know why I keep doing things the hard way. Wink
IP IP Logged
axelcore
Newbie
Newbie


Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 3
Quote axelcore Replybullet Posted: 28 May 2009 at 1:37pm
SmileSmileSmile  This worked great thanks for the help from both of you.  Much appreciated!!!!!
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.031 seconds.