add text to number field without losing leading zeros

H

Halfpint40601

I have a query column pulling numeric data: ex. 00008
I need to add an "A" to the beginning or end of the data without losing the
leading zeros. Thanks
 
J

John W. Vinson

I have a query column pulling numeric data: ex. 00008
I need to add an "A" to the beginning or end of the data without losing the
leading zeros. Thanks

A number is just a number - 8, 00008 and 0000000008 are all just ways of
depicting the exact same number.

To *display* the number with leading zeros you need to convert it to a text
string using the Format() function:

"A" & Format([numberfield], "00000")

will convert a number 8 into a text string "00008" and then append a letter A
to it.
 
S

SuzyQ

"A" & Right("00000" & [fieldname],5)

does the same thing, but your way looks cleaner.

John W. Vinson said:
I have a query column pulling numeric data: ex. 00008
I need to add an "A" to the beginning or end of the data without losing the
leading zeros. Thanks

A number is just a number - 8, 00008 and 0000000008 are all just ways of
depicting the exact same number.

To *display* the number with leading zeros you need to convert it to a text
string using the Format() function:

"A" & Format([numberfield], "00000")

will convert a number 8 into a text string "00008" and then append a letter A
to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top