Converting Pcaked Numbers - Module vs Function?

D

D Smith

I've worked with Access for years but never had to create a Module. I need to
convert Packed Numbers into proper decimal numbers (examples below). Not
being a VB programmer I'm not sure where/how to start. In other db apps there
was usually some facility to define your own functions and then use them in
queries. Can a Module serve that same purpose?

Thanks for any help on this!

Dave

Packed Number Translation:
In a Packed Number, the right-most digit is replaced by an Alpha character
that denotes 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

Thus:
Pack Number Decimal Number
00008660D = $866.04
00001751N = -$175.15
00000450{ = $45.00
00000450} = -$45.00
 
T

Tom Lake

D Smith said:
I've worked with Access for years but never had to create a Module. I need to
convert Packed Numbers into proper decimal numbers (examples below). Not
being a VB programmer I'm not sure where/how to start. In other db apps there
was usually some facility to define your own functions and then use them in
queries. Can a Module serve that same purpose?

A function is part of a module. A module is just a container for functions and subs.

Tom Lake
 
J

Jesper F

Packed Number Translation:
In a Packed Number, the right-most digit is replaced by an Alpha character
that denotes 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

Thus:
Pack Number Decimal Number
00008660D = $866.04
00001751N = -$175.15
00000450{ = $45.00
00000450} = -$45.00

Hi Dave. A function can do what you're asking and you can use it in your
queries.
A module kan contain many functions and subs. You'd usually group related
functions and subs in the same module.

You need a function such as:

Function GetPackedNo(DecimalNumber as double) as string
'kode that converts to packed
End Function

Your query could be:

UPDATE table1 SET packnumber = '" & GetPackedNo([decimalnumber]) & "'"




Jesper Fjølner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top