#51620 - 05/14/15 02:43 PM
I want to add leading Zero
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
I want to add leading zeros to show(field('bSuffix',&i)+'')
However when it is only 1 character I need 2 zeros When there is 2 characters I need 1 zero And finally non when there are three characters.
|
Top
|
|
|
|
#51621 - 05/14/15 03:34 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
JFLAIR
Unregistered
|
GBowlsby,
To add leading zeros you can use the right function.
right('000'+field,3)
This concatenates the 3 zeros with your data then takes the last 3 characters.
ex.: 000+563 = 000563 last 3 = 563 000+26 = 000026 = 026 000+1 = 000001 = 001
Hope this helps! Regards, JF
|
Top
|
|
|
|
#51622 - 05/14/15 03:45 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
Ok I need some help. I keep getting unknown instruction error
Here is what I have tried right('000'+'bSuffix',&i)+'' Show(right('000'+'bSuffix',&i)+'') right('000'+(field('bSuffix',&i)+''))) Show(right('000'+(field('bSuffix',&i)+'')))
So what is the correct syntax?
|
Top
|
|
|
|
#51623 - 05/14/15 03:49 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
Here is my full code if it helps.
%Define variables define(&paneleval, string, '') &paneleval := Field('bSuffix', &recnum) define(&i, integer, 0)
%Looop for each record on Data Page for(&i, 1, 1, subreccount())
setstyle(&style1) %Was Style2 for Underline show(field('bSuffix',&i)+'')
setstyle(&style1) show(' ')
setstyle(&style1) %Was Style2 for Underline show(field('tInvoiceName',&i)+'')
crlf(.2) endfor()
|
Top
|
|
|
|
#51624 - 05/14/15 04:10 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
Just got it.
show(right('000' + field('bSuffix', &i), 3))
|
Top
|
|
|
|
#51625 - 05/14/15 04:13 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
JFLAIR
Unregistered
|
GBowlsby, Here is the documentation. You need to specify how many characters you want to extract at the end of the string. right('000'+yourdata, number of char you want) You would also want an equal amount of 0 and the number of characters you want in your string. In your case it should be: show(right('000'+field('bSuffix',&i),3)) I'm not sure why you are adding +'' at the end. This adds nothing. Hope this helps! Regards, JF
|
Top
|
|
|
|
#51626 - 05/14/15 04:57 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
The reason I normally add the +' ' is because when I add the next field or string I forget spaces. But by having the +' ' I never forget spaces. lol
|
Top
|
|
|
|
#52151 - 07/27/15 07:22 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
Ok, additional question. I am having trouble with MS-Access starting the SeqNo field at 0 for the header rows, so is there a way I can minus 1 from my SeqNo field?
My SeqNo field is an integer with 1, 2, 3, to last record 1000
I am using =(right('000000' + field('SeqNo'), 6)), but where would I add -1
So record 1 would show as 000000 Record 2 would show 000002, etc..
This is a text box with a local variable
|
Top
|
|
|
|
#52152 - 07/27/15 07:22 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
Ok, additional question. I am having trouble with MS-Access starting the SeqNo field at 0 for the header rows, so is there a way I can minus 1 from my SeqNo field?
My SeqNo field is an integer with 1, 2, 3, to last record 1000
I am using =(right('000000' + field('SeqNo'), 6)), but where would I add -1
So record 1 would show as 000000 Record 2 would show 000002, etc..
This is a text box with a local variable
|
Top
|
|
|
|
#52153 - 07/27/15 07:23 PM
Re: I want to add leading Zero
[Re: GBowlsby]
|
OL Expert
Registered: 08/07/14
Posts: 167
Loc: Tallahassee FL
|
Ok, additional question. I am having trouble with MS-Access starting the SeqNo field at 0 for the header rows, so is there a way I can minus 1 from my SeqNo field?
My SeqNo field is an integer with 1, 2, 3, to last record 1000
I am using =(right('000000' + field('SeqNo'), 6)), but where would I add -1
So record 1 would show as 000000 Record 2 would show 000002, etc..
This is a text box with a local variable
|
Top
|
|
|
|
|
|