Adding two Sums together, with Nz

G

Guest

I have a query built upon other queries. In [qryContactsScores] and
[qryLeadsScores], I have a field which calculates the sum of a value, and
another field that runs a Nz expression on the first field.

When I run a third query to add together the two fields with the Nz
expression, it treats the "+" like an "&" sign. So instead of 2+2=4, I get
2+2=22. Any idea what I'm doing wrong?
 
G

Guest

What is the field type of the fields that you using for the sum?

It sound like it treating it as text fields, you can convert them to numbers
while adding them

Select Cdbl([Field1Name]) + Cdbl([Field2Name]) As NewField From TableName
 
G

Guest

they are number fields in the original table.

I did finally figure out a way around it. Instead of using
Nz([SumOfLeadsScores],0) I used IIf([SumOfLeadsScores] is Null, 0,
[SumOfLeadsScores])

It seems to work, but I don't know if that's the best way to do it.

Ofer said:
What is the field type of the fields that you using for the sum?

It sound like it treating it as text fields, you can convert them to numbers
while adding them

Select Cdbl([Field1Name]) + Cdbl([Field2Name]) As NewField From TableName

--
\\// Live Long and Prosper \\//
BS"D


kdagostino said:
I have a query built upon other queries. In [qryContactsScores] and
[qryLeadsScores], I have a field which calculates the sum of a value, and
another field that runs a Nz expression on the first field.

When I run a third query to add together the two fields with the Nz
expression, it treats the "+" like an "&" sign. So instead of 2+2=4, I get
2+2=22. Any idea what I'm doing wrong?
 
G

Guest

They both are the same thing, the NZ and the IIf should give the same resault.

--
\\// Live Long and Prosper \\//
BS"D


kdagostino said:
they are number fields in the original table.

I did finally figure out a way around it. Instead of using
Nz([SumOfLeadsScores],0) I used IIf([SumOfLeadsScores] is Null, 0,
[SumOfLeadsScores])

It seems to work, but I don't know if that's the best way to do it.

Ofer said:
What is the field type of the fields that you using for the sum?

It sound like it treating it as text fields, you can convert them to numbers
while adding them

Select Cdbl([Field1Name]) + Cdbl([Field2Name]) As NewField From TableName

--
\\// Live Long and Prosper \\//
BS"D


kdagostino said:
I have a query built upon other queries. In [qryContactsScores] and
[qryLeadsScores], I have a field which calculates the sum of a value, and
another field that runs a Nz expression on the first field.

When I run a third query to add together the two fields with the Nz
expression, it treats the "+" like an "&" sign. So instead of 2+2=4, I get
2+2=22. Any idea what I'm doing wrong?
 

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

Similar Threads

DLookup and Nz 0
Nz Function 10
Nz and Formats 1
Return ALL records with NZ function 4
Error when opening a my Query 5
Report Error "Database Engine" 5
totals for multiple fields 1
Correct Nz syntax when summing? 4

Top