convert text to number in VBA

  • Thread starter Thread starter gizzy
  • Start date Start date
G

gizzy

what function in VBA should I use to convert string field to a currency
or any numeric format?
I have a database that gets data from SQL server and all the values
there are stored in a character format, but i need to do some
mathematic functions on Access so i need numeric format

thanks in advance,
Gizzy
 
try

Int([FieldName])

Some of the functions you can check
Clng = Convert to Long
CDbl = Convert to Double
CCur = Convert to Currency
 
Thank you!

But what if i leave one of the fields blank?
if i use CCur(field2) then i get message "invalid use of null"
 
If you want to ignore nulls and return zeros where the text value is null,
use:

CCur(Nz([FieldName]))

MH
 
One method.

IIf(IsNumeric([FieldName]),Val([FieldName]),Null)
If you want to ignore nulls and return zeros where the text value is null,
use:

CCur(Nz([FieldName]))

MH

gizzy said:
Thank you!

But what if i leave one of the fields blank?
if i use CCur(field2) then i get message "invalid use of null"
 
Back
Top