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!

Formating number fields in fixed width export 1

Status
Not open for further replies.

mfd777

Programmer
Sep 21, 1999
53
IE
Hi all,<br>
<br>
I am exporting a query to a flat file. Everthing is o.k. except the &quot;quantity&quot; field at the end is a number and is going to the flat file as e.g. 48.00. I need the quantiy field to be 9 characters long with no decimal places. So a quantity of 48 should come out as 000000048<br>
I have set the format property of the field to fixed with no decimal places in the query but to no avail. I can't see anything in the export specification that I can change to help me.<br>
Thanks in advance.
 
Unfortunately Access has something a miss in formatting to ASCII.<br>
I have run into this before.<br>
the only way to get around this write your own Export routine.<br>
<br>
like <br>
Public Function ExportIt()<br>
Open &quot;C:\Myfile&quot; For Output As 1<br>
PadZeros = String(9 - Len(rst.Fields(&quot;quantity&quot;)), &quot;0&quot;)<br>
Write #1, PadZeros & Trim(rst.Fields(&quot;quantity&quot;))<br>
' write the rest of the fields out too<br>
Close #1<br>
End Function<br>
<br>
I agonized over the same thing spending days and days trying everthing I could think of.<br>
I was so close just one stinking field was wrong.<br>
It acually did'nt take as long as I though once I sat down and did it.<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
mfd777, is your problem solved? If not, I wonder if this would work for you if you defined your field as text then concatenated it with leading zeros. Access doesn't insert leading zeros into number fields.<br>
<br>
An example would be something like:<br>
Right(&quot;000000000&quot; & quantity,9)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top