ACC2000: change string to int

  • Thread starter Thread starter A Man
  • Start date Start date
A

A Man

I have a customer number that is a string, but I need to change it to an
integer variable. Assigning: iCust = sCust does not work. (I just want
to drop leading zeroes in the string. It can stay a string if that's
easy.)

Is there a function to convert string to int? I could not find one in
Access help. String() seems to convert a numeric to a string data type.

Thanks.
 
Try use:
Int(sCust)
or
Val(sCust)

If you want to find Help on these types of functions, first open any module
and then open Help.
 
Val(String) will return the value of the string; however it does return zero
if the string is just spaces and will error if the string is null
Val("22.5")

Better testing is
If IsNumeric(String) Then Val(String)

Or you could use
IIF(IsNumeric(String),Val(String),Null)


--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Try use:
Int(sCust)
or
Val(sCust)

If you want to find Help on these types of functions, first open any module
and then open Help.
Oh, THAT'S my problem. I thought all help files in Access were
integrated so when I did a search, it searched VBA help also.
 
Back
Top