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
|
|||
|
|||
REMOVING LEADING ZERO
I have loan numbers that consist of all numbers or alphanumeric fields. Not
all loan numbers have the same digits, however, they are all formatted to 35 character spaces. For example, one loan might be 123 (with zeros in front) and another loan would be 1245523, and another could be 1234abc1345. I need to format those with only numbers to a number value. I have used the Val() function and it works perfect with only number values, but when there is a loan that have alphanumeric, it shows up as 0. How do it have it show the loan number with the text? For example loan 00000abc123 needs to read abc123. |
#2
|
|||
|
|||
REMOVING LEADING ZERO
Jessica wrote:
I have loan numbers that consist of all numbers or alphanumeric fields. Not all loan numbers have the same digits, however, they are all formatted to 35 character spaces. For example, one loan might be 123 (with zeros in front) and another loan would be 1245523, and another could be 1234abc1345. I need to format those with only numbers to a number value. I have used the Val() function and it works perfect with only number values, but when there is a loan that have alphanumeric, it shows up as 0. How do it have it show the loan number with the text? For example loan 00000abc123 needs to read abc123. I think you will need to create a function to do that: Public Function Strip(v) Dim k As Long If IsNull(v) Then Exit Function For k = 1 To Len(v) - 1 If Mid(v, k, 1) "0" Then Exit For Next k Strip = Mid(v, k) End Function -- Marsh MVP [MS Access] |
#3
|
|||
|
|||
REMOVING LEADING ZERO
You can nest IIFs like this --
IIf(left([loan number],1)"0",[loan number], Iif(mid([loan number],2,1)"0",mid([loan number],2),iif(mid([loan number],3,1)"0",mid([loan number],3),"xxx"))) AS Expr1 You will need as many layers as you might have leading zeros. -- Build a little, test a little. "Jessica" wrote: I have loan numbers that consist of all numbers or alphanumeric fields. Not all loan numbers have the same digits, however, they are all formatted to 35 character spaces. For example, one loan might be 123 (with zeros in front) and another loan would be 1245523, and another could be 1234abc1345. I need to format those with only numbers to a number value. I have used the Val() function and it works perfect with only number values, but when there is a loan that have alphanumeric, it shows up as 0. How do it have it show the loan number with the text? For example loan 00000abc123 needs to read abc123. |
Thread Tools | |
Display Modes | |
|
|