|
-
March 11th, 2008, 01:20 PM
#1
Conditionally inserting lead zeros
I've searched through the forums, but can't find an answer specifically to what the results I'm trying to return.
The data in each column I'm returning is of varying lengths, i.e.:
123
1234
12345
I need to return results that conform to a set character length; let's say 10 characters total, i.e.:
0000000123
0000001234
0000012345
I've tried replicatestring, but that returns a set amount of whichever value you insert into the formlua, while I need it to conform to the result.
Any help would be GREATLY appreciated.
Thanks
-
March 11th, 2008, 01:36 PM
#2
Re: Conditionally inserting lead zeros
Try Format()
Code:
msgbox (Format(rst.num,"#########")
000000123
-
March 11th, 2008, 01:55 PM
#3
Re: Conditionally inserting lead zeros
You'll have to excuse me dglienna, I'm a bit of a noob. Would I be formatting the specific field, or creating a formula using the field to drop in?
If a formula, would it be:
format({dp_correction.check_no}, "##########")
-
March 11th, 2008, 05:04 PM
#4
Re: Conditionally inserting lead zeros
right(replicatestring("0", 10) & totext({table.field}, 0, ""), 10)
-
March 12th, 2008, 08:02 AM
#5
Re: Conditionally inserting lead zeros
That worked Jagan, thanks so much!
If I may, can I trouble you for one last issue?
One of the fields returns a dollar amount. Using the formula you provided, I came up with the following:
right(replicatestring("0", 10) & totext({dp_correction.amt},2,""), 10)
I understand that the '2' in the formula allows for two places after the decimal, but I need to completely remove the decimal from the result.
Is this possible?
Thanks again.
-
March 15th, 2008, 09:48 AM
#6
Re: Conditionally inserting lead zeros
Code:
right(replace(replicatestring("0", 10) & totext({dp_correction.amt},2,""),".",""), 10)
Try that?
-
March 15th, 2008, 10:21 AM
#7
Re: Conditionally inserting lead zeros
Wenin, that worked perfectly! I can't thank you enough.
Don't know if I can ever return the favor, but let me know if I can.
Thanks again.
-
March 15th, 2008, 10:41 AM
#8
Re: Conditionally inserting lead zeros
I'm just happy to be able to give back to this forum that I've gotten plenty of assistance from in the past. =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|