convert a field/column from kilos to metric tons

S

Sal

Its been a long time since I made a new field based on another one.

this should be fairly easy ... but I'm stumped.

any help - much appreciated

Sal
 
V

vanderghast

You make a query into which you add a computed expression, and use that
saved query where needed.


SELECT kilo, kilo*4.4482 AS pound
FROM somwhere



Alternatively, use the convertion on the fly, when you need it. Since it is
a computed expression, it is NOT updateable directly. If you need to make it
updateable, in a form, you can use TWO text-edit controls, one for kilo,
updeatable, but hidden (not visible) and one for pound. In the Current event
(of the form):

Me.pound = me.kilo*4.4482


and in the after update event of the control pound:


Me.kilo = me.pound / 4.4482



(you may have to tie other events too, but that is the general idea).


If you use a grid and dot-net, you can use only one column, and use the
Format event (to change the value from kilo to pound, since you want to
display a formatted value in pound) and the Parsing event (to change the
input pound to what is to be stored, kilo). That is a little bit cleaner and
more robust than using two controls, imho.



Vanderghast, Access MVP
 

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