A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

#Num question



 
 
Thread Tools Display Modes
  #1  
Old July 6th, 2006, 05:23 PM posted to microsoft.public.access.reports
Tony Williams
external usenet poster
 
Posts: 349
Default #Num question

I have a number of calculated controls on a report where the value of the
individual fields in the table is 0. I'm using this formula
=(Nz([Sum Of txtClients500],0)*Nz([txtclientstotal],0))/Nz([Sum Of
txtClientsTot],0)
Sum Of txtClients500 is a calculated control form a query being the total of
txtclients500
But I get the #Num error. Is there anything I can do to force a 0 if there
is no data in any of these controls?
Thanks
Tony


  #2  
Old July 6th, 2006, 05:36 PM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default #Num question

There's a possibility of a division by zero error here, so handle that case
specifically, and then perform the calculation (which may result in Null),
and use Nz() on that result.

Like this:
=IIF([Sum Of txtClientsTot] = 0, 0,
Nz([Sum Of txtClients500] * [txtclientstotal] / [Sum Of txtClientsTot],
0))

If that still fails, you may need to explicitly typecast those calculate
fields in their queries. Details in:
Calculated fields misinterpreted\
at:
http://allenbrowne.com/ser-45.html

--
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.

"Tony Williams" wrote in message
...
I have a number of calculated controls on a report where the value of the
individual fields in the table is 0. I'm using this formula
=(Nz([Sum Of txtClients500],0)*Nz([txtclientstotal],0))/Nz([Sum Of
txtClientsTot],0)
Sum Of txtClients500 is a calculated control form a query being the total
of txtclients500
But I get the #Num error. Is there anything I can do to force a 0 if there
is no data in any of these controls?



  #3  
Old July 6th, 2006, 06:06 PM posted to microsoft.public.access.reports
Tony Williams
external usenet poster
 
Posts: 349
Default #Num question

As ever Allen thanks that worked like a dream. Many thanks again
Tony
"Allen Browne" wrote in message
...
There's a possibility of a division by zero error here, so handle that
case specifically, and then perform the calculation (which may result in
Null), and use Nz() on that result.

Like this:
=IIF([Sum Of txtClientsTot] = 0, 0,
Nz([Sum Of txtClients500] * [txtclientstotal] / [Sum Of txtClientsTot],
0))

If that still fails, you may need to explicitly typecast those calculate
fields in their queries. Details in:
Calculated fields misinterpreted\
at:
http://allenbrowne.com/ser-45.html

--
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.

"Tony Williams" wrote in message
...
I have a number of calculated controls on a report where the value of the
individual fields in the table is 0. I'm using this formula
=(Nz([Sum Of txtClients500],0)*Nz([txtclientstotal],0))/Nz([Sum Of
txtClientsTot],0)
Sum Of txtClients500 is a calculated control form a query being the total
of txtclients500
But I get the #Num error. Is there anything I can do to force a 0 if
there is no data in any of these controls?





 




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


All times are GMT +1. The time now is 04:29 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.