Add two fields of a query together?

  • Thread starter Thread starter Andibevan
  • Start date Start date
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
 
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,
 
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
 
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.
 
'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
 

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

Back
Top