Author |
Message |
pittla1
Newbie
Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
|
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 Logged |
|
axelcore
Newbie
Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 3
|
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 Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
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 Logged |
|
axelcore
Newbie
Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 3
|
Posted: 28 May 2009 at 11:24am |
Yes if it is $12.13 it would be 00000001213
|
IP Logged |
|
pittla1
Newbie
Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
|
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 Logged |
|
pittla1
Newbie
Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
|
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
Hope this helps!
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|
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 Logged |
|
pittla1
Newbie
Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 4
|
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.
|
IP Logged |
|
axelcore
Newbie
Joined: 28 May 2009
Location: United States
Online Status: Offline
Posts: 3
|
Posted: 28 May 2009 at 1:37pm |
|
IP Logged |
|
|