D
D Smith
I have a file with packed numbers that I need to convert into decimal numbers.
I've written my 1st-ever Access Function but it does not return a result and
I get an error when I try it in Immediate Mode.
A "packed" number replaces the last (right-most) digit with a letter to
indicate both value and sign:
{=0 }=-0
A=1 J=-1
B=2 K=-2
C=3 L=-3
D=4 M=-4
E=5 N=-5
F=6 O=-6
G=7 P=-7
H=8 Q=-8
I=9 R=-9
So that 4950E = $495.05 and 4950N = -$495.05
My function so far:
Public Function UnPack(InNum As String)
Dim lastc As String -- lastc is used to store the last character
Dim firstc As String -- firstc is used to store the rest of the number
firstc = Left(InNum, 7) -- the numbers are all zero-filled: 0004950E
lastc = Right(InNum, 1)
Select Case lastc
Case "{"
InNum = (firstc + "0")
Case "A"
InNum = (firstc + "1")
Case "B"
InNum = (firstc + "2")
Case "C"
InNum = (firstc + "3")
Case "D"
InNum = (firstc + "4")
Case "E"
InNum = (firstc + "5")
Case "F"
InNum = (firstc + "6")
Case "G"
InNum = (firstc + "7")
Case "H"
InNum = (firstc + "8")
Case "I"
InNum = (firstc + "9")
Case "}"
InNum = (firstc + "0")
Case "J"
InNum = (firstc + "1")
Case "K"
InNum = (firstc + "2")
Case "L"
InNum = (firstc + "3")
Case "M"
InNum = (firstc + "4")
Case "N"
InNum = (firstc + "5")
Case "O"
InNum = (firstc + "6")
Case "P"
InNum = (firstc + "7")
Case "Q"
InNum = (firstc + "8")
Case "R"
InNum = (firstc + "9")
End Select
End Function
When I try to use this in a query, I get no results.
I know I'm missing something here but I don't know what...
Any thoughts?
Thanks!
Dave
I've written my 1st-ever Access Function but it does not return a result and
I get an error when I try it in Immediate Mode.
A "packed" number replaces the last (right-most) digit with a letter to
indicate both value and sign:
{=0 }=-0
A=1 J=-1
B=2 K=-2
C=3 L=-3
D=4 M=-4
E=5 N=-5
F=6 O=-6
G=7 P=-7
H=8 Q=-8
I=9 R=-9
So that 4950E = $495.05 and 4950N = -$495.05
My function so far:
Public Function UnPack(InNum As String)
Dim lastc As String -- lastc is used to store the last character
Dim firstc As String -- firstc is used to store the rest of the number
firstc = Left(InNum, 7) -- the numbers are all zero-filled: 0004950E
lastc = Right(InNum, 1)
Select Case lastc
Case "{"
InNum = (firstc + "0")
Case "A"
InNum = (firstc + "1")
Case "B"
InNum = (firstc + "2")
Case "C"
InNum = (firstc + "3")
Case "D"
InNum = (firstc + "4")
Case "E"
InNum = (firstc + "5")
Case "F"
InNum = (firstc + "6")
Case "G"
InNum = (firstc + "7")
Case "H"
InNum = (firstc + "8")
Case "I"
InNum = (firstc + "9")
Case "}"
InNum = (firstc + "0")
Case "J"
InNum = (firstc + "1")
Case "K"
InNum = (firstc + "2")
Case "L"
InNum = (firstc + "3")
Case "M"
InNum = (firstc + "4")
Case "N"
InNum = (firstc + "5")
Case "O"
InNum = (firstc + "6")
Case "P"
InNum = (firstc + "7")
Case "Q"
InNum = (firstc + "8")
Case "R"
InNum = (firstc + "9")
End Select
End Function
When I try to use this in a query, I get no results.
I know I'm missing something here but I don't know what...
Any thoughts?
Thanks!
Dave