Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2007
    Posts
    4

    Question Unanswered: Leading Zeroes in number

    hello there,
    anyone of you guys who has an idea on how to create a module which output a numeric value with leading zeroes

    for example:
    the value is 100 and i want a value should be look like this
    000000000000100 supposedly a 15 digits value
    anyway Im using access 2000.

    Thank you

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    There is a way - because I have done this before...
    I will look into it for you.

    Have you considered using a text field?

  3. #3
    Join Date
    Jan 2007
    Posts
    4
    My output should be a numeric field.
    So that in the event that there;s a decimal value, I can properly provide the
    exact value. anyway, if possible could you share it with me.

    thanks again

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    anything against using the format() function?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Dec 2006
    Posts
    53
    I have no doubt that with the VB string methods, this can be done.

    What are some of the particulars of your situation? What do you mean by "output," and what is the input? A form field?

    Can the format function add leading zeroes? I'd be surprised if it could. And, I can't imagine that any programming language would allow ANY numerically formatted field have leading zeroes. I am thinking that you will want to change the format to text/string at the last possible moment.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If the number is stored in a table, in a field with the data type "number" then it will always be stored in the table without leading zeroes. If this is the case, change the field in the table to text.

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by georgev
    If the number is stored in a table, in a field with the data type "number" then it will always be stored in the table without leading zeroes. If this is the case, change the field in the table to text.
    no. no. no.
    store data in the form that is appropriate for the data type. store numbers as numbers, text as text
    you change the format of the data in the presentation layer
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by healdem
    no. no. no.
    store data in the form that is appropriate for the data type. store numbers as numbers, text as text
    you change the format of the data in the presentation layer
    Ahh ok, good point. I suggested text beccause I thought it was to be stored with the leading zeroes attached.

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by dfwelch
    I have no doubt that with the VB string methods, this can be done.

    Can the format function add leading zeroes? I'd be surprised if it could. And, I can't imagine that any programming language would allow ANY numerically formatted field have leading zeroes. I am thinking that you will want to change the format to text/string at the last possible moment.
    ..its amazing what the help system can tell you.. that and also trying it.
    format is a predefined function in VBA
    <myformattedcolumn>Format(<myColumn>, "000000000000000")
    will give you a 15 digit number padded with leading zeros
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I tried that earlier but missed the quotes...
    That'll be why

  11. #11
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    i'd recomend just setting the format to "000000000000000" unless there's a pressing reason why you can't
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  12. #12
    Join Date
    Jan 2007
    Posts
    4
    Quote Originally Posted by dfwelch
    I have no doubt that with the VB string methods, this can be done.

    What are some of the particulars of your situation? What do you mean by "output," and what is the input? A form field?

    Can the format function add leading zeroes? I'd be surprised if it could. And, I can't imagine that any programming language would allow ANY numerically formatted field have leading zeroes. I am thinking that you will want to change the format to text/string at the last possible moment.
    Thanks for the info.
    As per your question, I want to input the value in form then the output should
    be stored in table as text padded with leading zeroes, could you provide
    me the sample code on how to do this.

    thanks bro.

  13. #13
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Just a thought:

    why not have an "On Lost Focus" event on the field of input.

    Code:
    Private Sub txtFieldName_LostFocus()
    
    txtFieldName = Format(txtfieldName,"0000000000")
    
    End Sub
    *shrugs*

  14. #14
    Join Date
    Jan 2007
    Posts
    4
    Thanks GEORGEV, now I got the idea.

    Thank you, thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •