Re: Long Integer truncates 0 at beginning of number

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



No, I don't think you need to redo all your coding. If the field in the
table where the value is stored is Numeric/Long, then anything that
references or modifies it as a number can be left as is.

The only time you need to present it as text is when you want to show it to
a human in that format. Then, you use the Format function or property as
Jeff said. That does not chage the original value or type unless you do so
specifically. For example, let's say you want to present it in a message box:

MsgBox "This Is A Formatted Number " & Format(lngSomeNumber, "000000")

Nothing has changed about the variable lngSomeNumber. It is just formated
for presentation so that it will always be presented with enought zeros to
make it six characters long.

If you want to change it to a string:
strConvertedNumber = Format(lngSomeNumber, "000000")

Now lngSomeNumber has still not changed, but we have a string variable that
contains a text representation of the number.


--
Dave Hargis, Microsoft Access MVP


"Piper" wrote:

Thanks for the response - I'm bummed, now I have to make it a string and
convert all that coding.

Oh well - I suppose I should have figured that out before I started coding!

Thanks
--
Piper


"Jeff Boyce" wrote:

Piper

Access is doing EXACTLY what you are telling it to do. Integers, Long or
otherwise, are whole numbers. From basic math, 1, 01, 001, and
00000000000000001 are all the same value, i.e,. 1!

If you need to show the digit 0 as the first character in a string of
characters (digits), then it is likely NOT a number (something you'd
add/subtract/multiply/divide). If you aren't doing math with it, maybe it's
"text", not "number".

Or, if you want to SEE preceding zeros on a true number (math, remember),
you can use the Format property or function to display those, regardless of
the value Access stores.

Regards

Jeff Boyce
Microsoft Office/Access MVP

"Piper" <Piper@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3AB225A2-2462-43FF-A6DD-2EB40BA27A93@xxxxxxxxxxxxxxxx
Hi -

I have a field of type Long, the data that goes in the field are numbers
like 027987 and 564982

Every time I enter a number with a 0 in front access takes the 0 out and
leaves me with 27987.

Is there anything I can do to keep the field type long? I've done a lot of
programming and I hate to loose it if I had to change the field type to
String.

Thanks
--
Piper




.



Relevant Pages

  • Re: Long Integer truncates 0 at beginning of number
    ... a human in that format. ... If you want to change it to a string: ... characters, then it is likely NOT a number (something you'd ... Is there anything I can do to keep the field type long? ...
    (microsoft.public.access.gettingstarted)
  • Re: Data Table Fields
    ... than the "field type" as you asked. ... Opinions should be accepted for what they are and not criticized. ... >> and you want to set its Format proerty to Short Date, ... >> intType As Integer, varValue As Variant, Optional strErrMsg As String) ...
    (microsoft.public.access.tablesdbdesign)
  • RE: How to import fixed-width text file(ragged right) in MS SQL 2005? C#.net handcode
    ... i don't want any wizard system plz.. ... ,file has to be imported by a user which has always same format so i need to do coding for that in C#.net ... no bulkinsert can't i have string to string copy ...
    (microsoft.public.sqlserver.clients)
  • How to format a string in resource
    ... part into bold type. ... Can I finish the format when I input the string into the ... resouce instead of using coding? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Please, PLEASE, hold your questions/comments/elsewhat til the end. Thank you. :)
    ... approximately those probabilities. ... So now you go through some horribly complex coding process and think ... You've produced an invalid code (a code that isn't uniquely ... Now do your coding on every possible input string of that length so ...
    (comp.compression)