Leading Zero's

G

Garry

I would like to add leading zero's in a text string

The string at the moment is made up of four fields

When I combine in a string I get for example

123456789 25 819 999

I require

123456789 00025 00819 999

Cheers
 
J

John W. Vinson

I would like to add leading zero's in a text string

The string at the moment is made up of four fields

When I combine in a string I get for example

123456789 25 819 999

I require

123456789 00025 00819 999

Cheers

Assuming you want patterns of 9, 5, 5, and 3 digits and leading zeros in all
of them, try

Right("000000000" & [field1], 9) & " " & Right("00000" & [Field2],5) & " " &
Right("00000" & [Field3],5) & " " & Right("000" & [Field3], 3)

I'm assuming that the fields are Text. If they're numbers this should still
work, though you might want to use

Format([field1, "000000000\ ") & Format([field2], "00000\ ") &
Format([field3], "00000\ ") & Format([field4], "000")

instead.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 

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