Mask a text data type as a number to perform calculation

G

Guest

I have a need to calculate a revised general ledger number (where the last two positions of the general ledger number are the department) in order to associate the correct department with the account. The general ledger number is stored as a text datatype in the database because of the need to apply an input mask to the general ledger number for other display purposes in the application

How do I apply a mask to convert the general ledger number as a number so that I can perform the departmental calculation and then store the result in the associated table as text

Thanks for your hel

-Barb
 
L

Larry Linson

Right$(<yourfieldname>, 2) will extract the last two digits of the field
whose name you supply. CInt will convert the characters to an Integer, CLng
will convert them to a long.

If you mean that the department number is used to determine the name of the
table in which to store the info, then you need to revisit your database
design. Using table names as "data" is a violation of relational database
design principles, and will come back to haunt you.

Larry Linson
Microsoft Access MVP

BarbM said:
I have a need to calculate a revised general ledger number (where the last
two positions of the general ledger number are the department) in order to
associate the correct department with the account. The general ledger
number is stored as a text datatype in the database because of the need to
apply an input mask to the general ledger number for other display purposes
in the application.
How do I apply a mask to convert the general ledger number as a number so
that I can perform the departmental calculation and then store the result in
the associated table as text?
 

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