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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

convert "Text" into "Number"



 
 
Thread Tools Display Modes
  #1  
Old March 11th, 2008, 09:22 AM posted to microsoft.public.access.queries
Ali
external usenet poster
 
Posts: 221
Default convert "Text" into "Number"

I have a a table (due to many reasons!), my query of "price" is text,


Now,

I want to convert it from "Text" into "Number".

(Because later on i need to export it to other system)




Thanks a lot , dear expert!
--
Allen Phailat Wongakanit
  #2  
Old March 11th, 2008, 10:45 AM posted to microsoft.public.access.queries
Keith Wilby
external usenet poster
 
Posts: 812
Default convert "Text" into "Number"

"ali" wrote in message
...
I have a a table (due to many reasons!), my query of "price" is text,


Now,

I want to convert it from "Text" into "Number".

(Because later on i need to export it to other system)



CInt or CLng should do it.

Keith.

  #3  
Old March 11th, 2008, 11:09 AM posted to microsoft.public.access.queries
Ofer Cohen
external usenet poster
 
Posts: 1,683
Default convert "Text" into "Number"

Clng and Cint will round the number,
34.4

will turn to 34

if you don't want the number to round, use
CDbl([YourNumber]) or Val([YourNumber])


--
Good Luck
BS"D


"Keith Wilby" wrote:

"ali" wrote in message
...
I have a a table (due to many reasons!), my query of "price" is text,


Now,

I want to convert it from "Text" into "Number".

(Because later on i need to export it to other system)



CInt or CLng should do it.

Keith.


  #4  
Old March 11th, 2008, 04:56 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default convert "Text" into "Number"

On Tue, 11 Mar 2008 02:22:00 -0700, ali wrote:

I have a a table (due to many reasons!), my query of "price" is text,


Now,

I want to convert it from "Text" into "Number".

(Because later on i need to export it to other system)


I'll reluctantly have to disagree with both Ofer and Keith here. If the price
is a currency value, you want to convert it to Currency: CCur([price]) will do
it, with some caveats.

For one, CCur will only work if the number in the text field is just a number.
Whitespace and currency symbols such as $ are ok, but if there is other text
in the field, or if there are NULL values, you'll get errors.

What is actually IN your Price field? Could you post some examples? And what
are some of the reasons that you are storing non-currency data in a Price
field?
--

John W. Vinson [MVP]
  #5  
Old December 29th, 2009, 11:47 PM posted to microsoft.public.access.queries
E-mail report using Lotus Notes rather t
external usenet poster
 
Posts: 105
Default convert "Text" into "Number"

Hi Keith,

I can't seem to convert text a field into a number using query.


FILED_ID: Cint([TableName]![FieldName])

When I use the expression above, it just returned an empty text filed after
executing the query.

Please help...this conversion is driving be nuts.

Thank you.



"ali" wrote:

I have a a table (due to many reasons!), my query of "price" is text,


Now,

I want to convert it from "Text" into "Number".

(Because later on i need to export it to other system)




Thanks a lot , dear expert!
--
Allen Phailat Wongakanit

  #6  
Old December 30th, 2009, 12:32 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default convert "Text" into "Number"

On Tue, 29 Dec 2009 15:47:02 -0800, E-mail report using Lotus Notes rather t
rosoft.com wrote:

Hi Keith,

I can't seem to convert text a field into a number using query.


FILED_ID: Cint([TableName]![FieldName])

When I use the expression above, it just returned an empty text filed after
executing the query.

Please help...this conversion is driving be nuts.


What's the context? What's the actual value of FieldName?

You should be using . rather than ! as a delimiter here, and (if there is only
one field of this name) you can omit the TableName altogether:

FILED_ID: CInt([TextFieldName])

will return an integer 3 if TextFieldName is a Text field in the query
containing the text string "3".

If the field contains "Three" instead... you've got a harder problem!
--

John W. Vinson [MVP]
  #7  
Old December 30th, 2009, 12:58 AM posted to microsoft.public.access.queries
E-mail report using Lotus Notes rather t
external usenet poster
 
Posts: 105
Default convert "Text" into "Number"

Keith the below expression, there is a limit on how many rows it can convert
to long Integer. Is there another way to extent to great then the number
below?

test: CLNG([FieldName])

only convert text to numbers up until 900099999


thanks.

"Ofer Cohen" wrote:

Clng and Cint will round the number,
34.4

will turn to 34

if you don't want the number to round, use
CDbl([YourNumber]) or Val([YourNumber])


--
Good Luck
BS"D


"Keith Wilby" wrote:

"ali" wrote in message
...
I have a a table (due to many reasons!), my query of "price" is text,


Now,

I want to convert it from "Text" into "Number".

(Because later on i need to export it to other system)



CInt or CLng should do it.

Keith.


  #8  
Old December 30th, 2009, 01:29 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default convert "Text" into "Number"

On Tue, 29 Dec 2009 16:58:01 -0800, E-mail report using Lotus Notes rather t
rosoft.com wrote:

Keith the below expression, there is a limit on how many rows it can convert
to long Integer. Is there another way to extent to great then the number
below?


There is no limit on the number of *rows*.

test: CLNG([FieldName])

only convert text to numbers up until 900099999


There is a limit on the size of the number. A Long Integer (the output of
CLng) is a 32 bit signed integer with a valid range of values from -2147483648
through 2147483647. 900099999 is well within this range:

?clng("900099999")
900099999
?clng("2147483647")
2147483647
?clng("2147483648")
generates an overflow error

Originally, you were using CInt(), which generates a small (16 bit) integer,
which is limited to the range -65536 to 65535.

Could you explain the nature of the data, the range of values you're using,
and just what you are trying to accomplish?
--

John W. Vinson [MVP]
 




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


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