ACC2000: change string to int

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.
 
D

Duane Hookom

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.
 
J

John Spencer

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
..
 
A

A Man

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.
 

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