View Full Version : Trim Query


KevW
05-02-2007, 02:47 PM
Using the built in function within access 2000 how can I do the following

I have the following types of number in a table

84125
80245

I want to be able to trim the leading 8 of the first number but on secon number I need to trim the 80 off the number.

I can quite easily trim off the 8 off both numbers t am left with a leading 0 on the second number. This has to also be trimmed.

The number will always be 5 digits long


Is there anyway of doing this by using the built in function Len or is there another way

Thanks

RuralGuy
05-02-2007, 03:22 PM
How about:
Public Function TrimNum(InNum As String) As String

If Mid(InNum, 2, 1) = "0" Then
TrimNum = Right(InNum, Len(InNum) - 2)
Else
TrimNum = Right(InNum, Len(InNum) - 1)
End If

End Function