dbTalk Databases Forums  

Syntax for using Nz function to handle blank fields in a querycalculation

comp.databases.ms-access comp.databases.ms-access


Discuss Syntax for using Nz function to handle blank fields in a querycalculation in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Will
 
Posts: n/a

Default Syntax for using Nz function to handle blank fields in a querycalculation - 03-06-2008 , 08:35 AM






Hi,

I need to handle blank values in a query calculation. I have 636
records at the moment but when I sum over these records the blank
fields are not returned. I have looked around here and on Access help
and the Nz function seems to be the way forward.

I am summing over 6 fields, all or none of which may contain values.
The expression syntax I have used is as follows:

BU Weighting SUM: Nz([BU.Weighting],0)+Nz([BU_1.Weighting],
0)+Nz([BU_2.Weighting],0)+Nz([BU_3.Weighting],0)+Nz([BU_4.Weighting],
0)+Nz([BU_5.Weighting],0)

However when I run the query only the 37 records that contain 6 non
Null values in the specified fields are returned. I can't see how my
syntax is incorrect in comparison to the Access Help files.

Any help appreciated.

Thanks,

Will

Reply With Quote
  #2  
Old   
Allen Browne
 
Posts: n/a

Default Re: Syntax for using Nz function to handle blank fields in a query calculation - 03-06-2008 , 08:43 AM






The problem is not with this calculated field. It is with the query itself.

You could verify that by omitting the calculated field, and you would still
only get the same number of records returned.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Will" <willcull (AT) yahoo (DOT) com> wrote

Quote:
I need to handle blank values in a query calculation. I have 636
records at the moment but when I sum over these records the blank
fields are not returned. I have looked around here and on Access help
and the Nz function seems to be the way forward.

I am summing over 6 fields, all or none of which may contain values.
The expression syntax I have used is as follows:

BU Weighting SUM: Nz([BU.Weighting],0)+Nz([BU_1.Weighting],
0)+Nz([BU_2.Weighting],0)+Nz([BU_3.Weighting],0)+Nz([BU_4.Weighting],
0)+Nz([BU_5.Weighting],0)

However when I run the query only the 37 records that contain 6 non
Null values in the specified fields are returned. I can't see how my
syntax is incorrect in comparison to the Access Help files.

Any help appreciated.

Thanks,

Will


Reply With Quote
  #3  
Old   
Will
 
Posts: n/a

Default Re: Syntax for using Nz function to handle blank fields in a querycalculation - 03-06-2008 , 09:04 AM



On Mar 6, 2:43*pm, "Allen Browne" <AllenBro... (AT) SeeSig (DOT) Invalid> wrote:
Quote:
The problem is not with this calculated field. It is with the query itself..

You could verify that by omitting the calculated field, and you would still
only get the same number of records returned.

--
Allen Browne - Microsoft MVP. *Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


Thats correct, thanks. Needed to change to an outer join.


Reply With Quote
Reply




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 On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.