Problem using the Format statement

ShellWorker

Registered User.
Local time
Today, 11:12
Joined
Sep 23, 2008
Messages
12
Here’s the problem:

When I execute the following line of code:
Format(X, "000000")
Where X = "0S111", It returns:
0S111
Which is what I want.

But...

When I execute the same line of code where X = "0E111", It returns:
000000
Which is NOT what I want. I wanted it to return:
0E111

Any ideas?
 
ShellWorker,

You may need to add "Trim" to the declaration like:

Trim(Format(x, "@@@@@&"))

At least I had to when I tested vbaInet's format code, other wise I got a space at the start of the resulting string.
 
ShellWorker,

You may need to add "Trim" to the declaration like:

Trim(Format(x, "@@@@@&"))

At least I had to when I tested vbaInet's format code, other wise I got a space at the start of the resulting string.
Good thing you tested it Mr. B

Great tip for the OP to trim.

Thanks
 
No, problem. I just wanted to see for myself what was going on with the format thing. You came up with an interesting fix.

Great job.
 
Just a footnote to this thread the poster said that 0E111 did not work, itg may be that Access thinks that this is an expotential number and rounds it to 0 thus the formatting of 000000 is infact correct. To prove this try using other letters than E.
 
Ah yes, that's what it's doing there David. So it works but was just used for the wrong purpose.
 

Users who are viewing this thread

Back
Top Bottom