Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with leading zeros and blank fill in the same field

Status
Not open for further replies.

bng

Technical User
Feb 25, 2000
2
US
I have a 20 space text field that currently has data with varying lengths of numbers from 3-8 characters. For the purpose of creating an ASCII file I need to add zeros to front of the numbers to make them all 10 characters and fill 10 spaces at the end. Please help.<br>
<br>
Thank you in advance.
 
You can use the following public function in a update query that updates the 20 space field<br>
<br>
function AddZero(Fieldname as string) as string<br>
dim i as integer<br>
for i=1 to 10<br>
addzero=&quot;0&quot; & fieldname<br>
if len(addzero)=10<br>
exit for<br>
endif<br>
next i<br>
addzero=addzero & &quot;0000000000&quot;<br>
end function<br>

 
Another way is to use string functions within the query:<br>
newfield: right(&quot;0000000000&quot; & oldfield) & &quot;0000000000&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top