Change field data type using query

G

Guest

Hi All,

I have two fields in access table. One is MinVal and other is ActVal. I have
imported this data from some escel sheet. Both the fields contain numbers.
But while importing, the access filed data types for both the fields is
'Text'. Now I want to compare these two fields and update it as:

ActVal=If(ActVal<MinVal,MinVal, ActVal).

Since, the data type is 'Text', I cannot compare it. Also due to some
restrictions, I cannot change the field data type permanently. I want to
change the data type to 'Number' for comparison only and again change the
data type back to 'Text'.

Is it possible?
Thank You in advance.


Regards,
Pawan
 
R

Roger Carlson

What type of numeric data is it? If integer, I suggest:

ActVal=IIf(CLng(ActVal)<CLng(MinVal),MinVal, ActVal).

I use Long Integer rather than Integer in most cases because of the limit on
the size of integer.

If they have decimal values, I suggest the currency datatype

ActVal=IIf(CCur(ActVal)<CCur(MinVal),MinVal, ActVal).

Currency works best if you don't need decimal precision of more than 4
decimal places. Comparing floating point values (Single or Double) can
sometimes produce erroneous results.


--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 

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