A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

ACC2000: change string to int



 
 
Thread Tools Display Modes
  #1  
Old January 30th, 2008, 04:54 PM posted to microsoft.public.access.reports
A Man
external usenet poster
 
Posts: 29
Default ACC2000: change string to int

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.
  #2  
Old January 30th, 2008, 05:06 PM posted to microsoft.public.access.reports
Duane Hookom
external usenet poster
 
Posts: 7,177
Default ACC2000: change string to int

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.

--
Duane Hookom
Microsoft Access MVP
If I have helped you, please help me by donating to UCP
http://www.access.hookom.net/UCP/Default.htm


"A Man" wrote:

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.

  #3  
Old January 30th, 2008, 05:11 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default ACC2000: change string to int

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 Man" wrote in message
. net...
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.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:34 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.