Change field data type using query

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top