If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Number Data Type Field and Leading Zeros
I have a table that has one field set to a number data
type. As part of the values input process, I need to enter values leading with a zero as the first digit. Unfortunately, every time we try to enter one of these values, Access drops the leading zero automatically. Also, I can't change the data type to text since programming code in other applications tied in to this table require the field to be a number data type. Any suggestions on how to keep the leading zero as part of the values without having to change the data type? Thank you. |
#2
|
|||
|
|||
Number Data Type Field and Leading Zeros
Any suggestions on how to keep the leading zero as part of
the values without having to change the data type? Hi Carlos, Leading zeros have no meaning with numeric values: 1 = 01 = 0001, etc. If the data must be numeric but you need the humans to work with a certain format, you must convert to String for display. Try something like this, using 8 as an example: Dim str as String Dim int As Integer int = 123 str = CStr(int) Do While (Len(str) 8) str = "0" & str Loop ''' str = "00000123" ''' CInt(str) = 123 Jay |
#3
|
|||
|
|||
Number Data Type Field and Leading Zeros
Can't be done with a number formatted field. You will have to change the
field to text format. Text can easily be converted to numbers via Val function and other means. Your other programs will need to do the conversion. -- Ken Snell MS ACCESS MVP "Carlos" wrote in message ... I have a table that has one field set to a number data type. As part of the values input process, I need to enter values leading with a zero as the first digit. Unfortunately, every time we try to enter one of these values, Access drops the leading zero automatically. Also, I can't change the data type to text since programming code in other applications tied in to this table require the field to be a number data type. Any suggestions on how to keep the leading zero as part of the values without having to change the data type? Thank you. |
#4
|
|||
|
|||
Number Data Type Field and Leading Zeros
Hi Carlos,
As others have said, a leading zero cannot form part of a numeric value: 12345 is the same *number* as 012345, though not the same string of characters. But you can *display* leading zeroes by setting the Format property of the control or field to something like 00000 On Tue, 27 Jul 2004 15:32:08 -0700, "Carlos" wrote: I have a table that has one field set to a number data type. As part of the values input process, I need to enter values leading with a zero as the first digit. Unfortunately, every time we try to enter one of these values, Access drops the leading zero automatically. Also, I can't change the data type to text since programming code in other applications tied in to this table require the field to be a number data type. Any suggestions on how to keep the leading zero as part of the values without having to change the data type? Thank you. -- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email. |
#5
|
|||
|
|||
Number Data Type Field and Leading Zeros
Or by using "Right$("00000000" & [ValueField],8)
"John Nurick" wrote in message ... Hi Carlos, As others have said, a leading zero cannot form part of a numeric value: 12345 is the same *number* as 012345, though not the same string of characters. But you can *display* leading zeroes by setting the Format property of the control or field to something like 00000 On Tue, 27 Jul 2004 15:32:08 -0700, "Carlos" wrote: I have a table that has one field set to a number data type. As part of the values input process, I need to enter values leading with a zero as the first digit. Unfortunately, every time we try to enter one of these values, Access drops the leading zero automatically. Also, I can't change the data type to text since programming code in other applications tied in to this table require the field to be a number data type. Any suggestions on how to keep the leading zero as part of the values without having to change the data type? Thank you. -- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Linked Table field...strip off leading zeros of text | Inyo55 | Database Design | 1 | July 24th, 2004 01:11 AM |
Leading Zeros | murfitUK | New Users | 2 | July 3rd, 2004 10:47 PM |
Automatic Preceeding Zeros in a field e.g. 00001234 | DD | Database Design | 2 | June 19th, 2004 05:55 AM |
Remove leading 0's from Text field | Bruce | Database Design | 3 | May 13th, 2004 12:03 AM |
Removing leading characters from word field | Peter Wilde | Mailmerge | 2 | May 4th, 2004 12:01 PM |