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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Leading zeros

Status
Not open for further replies.

pkw25

MIS
Mar 20, 2002
46
0
0
IE

Hello

How do you insert leading zeros to a query output.
Eg. one field returns a six digit customer number 090579.
How can I get this displayed as 00000090579. I think it may have somethinf to do with properties and format. Any help would be appreciated on this matter.

Paraic.
 
Hi Paraic!

In your query use this field:

NewNumber: Format([YourTable]![YourField], "00000000000")

You can name the field whatever you like, of course you will need the actual names of the table and field instead of the placeholders I have used.

hth
Jeff Bridgham
bridgham@purdue.edu
 
If it REALLY is a number then it will return 90579 without ANY leading zeros. I therefore suspect that you have a text string set equal to the characters "090579"

In this case you need
txtDisplayControl = "00000" & txtCustomerNo


G LS
 
Or you could typecast the textstring to a number,
this would yield:
Code:
txtDisplayControl = Format(CLng(txtCustomerNo),"000000000")
This will only work of course, if the value in
txtCustomerNo can actually be converted into a number.

Hope this helps...

Kim
 

Thanks for your replies. Jeff's solution worked ok so I haven't really investigated the others yet.
I required the leading Zero's because I wan't to output the query to a file and send it to a printing agency to do our companies invoicing. They require an OCR codeline with set digit length.

Thanks Again

Paraic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top