Thanks!
Val([Number]) returns a number in double format.
CInt, CDbl, CLng, CSng will all convert string numbers in there respective
ranges to Integers, Double floating point, Long integers, and Single
floating point.
CCur converts to a number also with four decimal places of accuracy.
"EA" <E...@discussions.microsoft.com> wrote in message
news:A3F86B02-636B-46A8...@microsoft.com...
CDbl("123") = 123
CDbl("123.1") = 123.1
Val("123.1") = 123.1
Val("123.1a") = 123.1
Val("12a3.1") = 12
The CDbl will choke on data that can't be evaluated as a number or nulls.
CDbl("123a") = Type mismatch error.
CDbl(null) = invalid use of null
Therefore you might first check your data with the IsNumeric function.
IsNumeric(null) = false
IsNumeric("12 3") = false
IsNumeric("12A3") = false
IsNumeric("123") = true
--
Jerry Whittle
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
Say that the field name is [StreetNumber], you would change it to
CLng([StreetNumber]). Now Access will make it look something like:
Expr1: CLng([StreetNumber])
You can change the Expr1 part before the colon to something like :
StreetNum: CLng([StreetNumber])
Now for checking that the number can be changed to a number, put something
like this in another field:
IsNumeric([StreetNumber])
In the Criteria put Yes or -1. The Yes should not have quotation marks
around it.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
>How do you use this in the SQL query so the output data is a number?
>
>"Jerry Whittle" wrote:
>
>> You can use the something like the CDbl or Val functions. CDbl changes the
>> text to a number. Val changes any leading characters that are numerical to a
>> number. See examples below.
>>
>> CDbl("123") = 123
>> CDbl("123.1") = 123.1
>> Val("123.1") = 123.1
>> Val("123.1a") = 123.1
>> Val("12a3.1") = 12
Put your choice of the expressions (or use CLng or CInt for whole numbers) in
a vacant Field cell in the query grid.
John W. Vinson [MVP]
I do not know what a QBE grid is. I have been using MSQuery as a query
editing tool. I can modify the query directly.
SELECT TSKVAROCALINE.NAME, TASK_VARIABLES_OCCURRENCES.NAME,
TASK_VARIABLES_OCCURRENCES.VARIABLEVALUE, TASK.CREATOR,
TASK_VARIABLES_OCCURRENCES.VARIABLETIME
FROM OPS$OCSHIS.TASK TASK, OPS$OCSHIS.TASK_VARIABLES_OCCURRENCES
TASK_VARIABLES_OCCURRENCES, OPS$OCSHIS.TSKVAROCALINE TSKVAROCALINE
WHERE TASK.TASKID = TASK_VARIABLES_OCCURRENCES.TASKID AND
TSKVAROCALINE.VARIABLEVALUE = TASK.CREATOR AND
((TASK_VARIABLES_OCCURRENCES.NAME Like '%tt') AND
(TASK_VARIABLES_OCCURRENCES.VARIABLETIME>? And
TASK_VARIABLES_OCCURRENCES.VARIABLETIME<?) OR
(TASK_VARIABLES_OCCURRENCES.NAME In ('CL2 Used','PVC Used')) AND
(TASK_VARIABLES_OCCURRENCES.VARIABLETIME>? And
TASK_VARIABLES_OCCURRENCES.VARIABLETIME<?))
ORDER BY TASK.CREATOR
In my SQL query how would I change the
TASK_VARIABLES_OCCURANCES.VARIABLEVALUE into a number?
I am using MSquery to build the query. I can add a field or rename a field
if that would help.
Thanks in advance
SELECT TSKVAROCALINE.NAME, TASK_VARIABLES_OCCURRENCES.NAME,
TASK_VARIABLES_OCCURRENCES.VARIABLEVALUE, TASK.CREATOR,
TASK_VARIABLES_OCCURRENCES.VARIABLETIME
FROM OPS$OCSHIS.TASK TASK, OPS$OCSHIS.TASK_VARIABLES_OCCURRENCES
TASK_VARIABLES_OCCURRENCES, OPS$OCSHIS.TSKVAROCALINE TSKVAROCALINE
WHERE TASK.TASKID = TASK_VARIABLES_OCCURRENCES.TASKID AND
TSKVAROCALINE.VARIABLEVALUE = TASK.CREATOR AND
((TASK_VARIABLES_OCCURRENCES.NAME Like '%tt') AND
(TASK_VARIABLES_OCCURRENCES.VARIABLETIME>? And
TASK_VARIABLES_OCCURRENCES.VARIABLETIME<?) OR
(TASK_VARIABLES_OCCURRENCES.NAME In ('CL2 Used','PVC Used')) AND
(TASK_VARIABLES_OCCURRENCES.VARIABLETIME>? And
TASK_VARIABLES_OCCURRENCES.VARIABLETIME<?))
ORDER BY TASK.CREATOR
>Hi John,
>I do not understand your suggestion.
>
>In my SQL query how would I change the
>TASK_VARIABLES_OCCURANCES.VARIABLEVALUE into a number?
SELECT TSKVAROCALINE.NAME, TASK_VARIABLES_OCCURRENCES.NAME,
CLng(TASK_VARIABLES_OCCURRENCES.VARIABLEVALUE) AS VValue, TASK.CREATOR,
TASK_VARIABLES_OCCURRENCES.VARIABLETIME
FROM OPS$OCSHIS.TASK TASK, OPS$OCSHIS.TASK_VARIABLES_OCCURRENCES
TASK_VARIABLES_OCCURRENCES, OPS$OCSHIS.TSKVAROCALINE TSKVAROCALINE
WHERE TASK.TASKID = TASK_VARIABLES_OCCURRENCES.TASKID AND
TSKVAROCALINE.VARIABLEVALUE = TASK.CREATOR AND
((TASK_VARIABLES_OCCURRENCES.NAME Like '%tt') AND
(TASK_VARIABLES_OCCURRENCES.VARIABLETIME>? And
TASK_VARIABLES_OCCURRENCES.VARIABLETIME<?) OR
(TASK_VARIABLES_OCCURRENCES.NAME In ('CL2 Used','PVC Used')) AND
(TASK_VARIABLES_OCCURRENCES.VARIABLETIME>? And
TASK_VARIABLES_OCCURRENCES.VARIABLETIME<?))
ORDER BY TASK.CREATOR
John W. Vinson [MVP]
I tried your suggestion and the reply I get is. ORA-00923: FROM keyword not
found where expected.
I am querying a Oracle database.
Any other suggestions?
>Hello John,
>
>I tried your suggestion and the reply I get is. ORA-00923: FROM keyword not
>found where expected.
>
>I am querying a Oracle database.
ummmmmm....
Thanks. You didn't say that, and my telepathy was on the blink.
>Any other suggestions?
Build the query using Oracle PL-SQL (which I don't remember over the ten or
twelve years since I've used it).
John W. Vinson [MVP]
>Does that have a plug in to Excel?
I'm not expert in Excel, and even less so in PL-SQL... sorry!
John W. Vinson [MVP]
I used the CLNG([fieldName]) to change a text field into a number field.
But the text field are number format with decimals. When I convert the
field, it does not have decimal places but it rounds up for me. Is there a
way to convert to number with the decimal?
example text field: 20.1
Converted into number field: 20.1 not 20
thank you so much.