Add two fields of a query together?

A

Andibevan

I am trying to add two fields from another query together in a query. I
want to add the fields together - [qry_AB_Metrics_4].[1
Critical]+[qry_AB_Metrics_4].[2 High] but there is a problem. If the
Critical and High values are 8 and 6 respectively - the total is 86 not 14.

How do you add two fields of a query together?

SELECT qry_AB_Metrics_4.Range, qry_AB_Metrics_4.Total,
([qry_AB_Metrics_4].[1 Critical]+[qry_AB_Metrics_4].[2 High]) AS High,
qry_AB_Metrics_4.[3 Medium] AS Medium, qry_AB_Metrics_4.[4 Low] AS Low

FROM qry_AB_Metrics_4;



TIA



Andi
 
D

Duane Hookom

Apparently your query qry_AB_Metrics_4 is returning the values a text. You
can wrap each field in Val() to conver to numeric.
Val([1 Critical])+Val([2 High]) As High,
 
T

Tom Lake

I am trying to add two fields from another query together in a query. I
want to add the fields together - [qry_AB_Metrics_4].[1
Critical]+[qry_AB_Metrics_4].[2 High] but there is a problem. If the
Critical and High values are 8 and 6 respectively - the total is 86 not 14.

How do you add two fields of a query together?

They are obviously text fields rather than numeric. try this:

Val([1 Critical]) + Val([2 High])

Tom Lake
 
R

Rick B

Sounds like it is concatenating strings, not adding values.

The fields you are using must be text fields, not numeric.

I think you can use the "Val" function to convert them, or just fix the data
types for the fields if they should truly be numeric.
 
A

Andibevan

'Thanks all - that did the trick.

Rick B said:
Sounds like it is concatenating strings, not adding values.

The fields you are using must be text fields, not numeric.

I think you can use the "Val" function to convert them, or just fix the data
types for the fields if they should truly be numeric.


--
Rick B



Andibevan said:
I am trying to add two fields from another query together in a query. I
want to add the fields together - [qry_AB_Metrics_4].[1
Critical]+[qry_AB_Metrics_4].[2 High] but there is a problem. If the
Critical and High values are 8 and 6 respectively - the total is 86 not
14.

How do you add two fields of a query together?

SELECT qry_AB_Metrics_4.Range, qry_AB_Metrics_4.Total,
([qry_AB_Metrics_4].[1 Critical]+[qry_AB_Metrics_4].[2 High]) AS High,
qry_AB_Metrics_4.[3 Medium] AS Medium, qry_AB_Metrics_4.[4 Low] AS Low

FROM qry_AB_Metrics_4;



TIA



Andi
 
Top