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  

Replace zeros with "-" in reports



 
 
Thread Tools Display Modes
  #1  
Old July 20th, 2007, 06:58 PM posted to microsoft.public.access.reports
hadi
external usenet poster
 
Posts: 44
Default Replace zeros with "-" in reports

Hello Experts,

I have a report that based on a query. The query adds up my monthly hours
for the people that work on the project and the report displays the result.
my formula in the query to calculate total forJanuary for example is 07Jan:
Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]). So all I do is add
the field 07Jan into my report. The problem am having is I like to replace
all the 0.00 totals with "-". I try to do IIF(Nz([07Jan]=0,"-",Nz([07Jan])
but I get an #Error in the repot. The only way I got to work is by using a
text box and if I repeat the whole formula in the report as well by saying:
IIF(Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4])=0,"-",Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]))
but I am defeating the point of using the query to calcuate my totals. I am
sure there is a simple way to do it but can't get there

Help is always appreciated

Hadi

  #2  
Old July 20th, 2007, 07:06 PM posted to microsoft.public.access.reports
hadi
external usenet poster
 
Posts: 44
Default Replace zeros with "-" in reports

Never mind. I figured out what I was doing wrong. I was typing the IF
statement in the field box itself not a seperate text box.

thanks anyways

"Hadi" wrote:

Hello Experts,

I have a report that based on a query. The query adds up my monthly hours
for the people that work on the project and the report displays the result.
my formula in the query to calculate total forJanuary for example is 07Jan:
Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]). So all I do is add
the field 07Jan into my report. The problem am having is I like to replace
all the 0.00 totals with "-". I try to do IIF(Nz([07Jan]=0,"-",Nz([07Jan])
but I get an #Error in the repot. The only way I got to work is by using a
text box and if I repeat the whole formula in the report as well by saying:
IIF(Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4])=0,"-",Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]))
but I am defeating the point of using the query to calcuate my totals. I am
sure there is a simple way to do it but can't get there

Help is always appreciated

Hadi

  #3  
Old July 20th, 2007, 07:07 PM posted to microsoft.public.access.reports
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default Replace zeros with "-" in reports

You could try using the Format property of the text box in which the
calculation is being displayed. Formats for numeric fields can have up to
four sections defined, with each section separated by semi-colons. The first
section is the format for positive numbers, the second section is the format
for negative numbers, the third section is the format for zero values, and
the fourth section is the format for Null values.

You could use something like

#.0;(#.0);"-";"-"


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Hadi" wrote in message
...
Hello Experts,

I have a report that based on a query. The query adds up my monthly hours
for the people that work on the project and the report displays the
result.
my formula in the query to calculate total forJanuary for example is
07Jan:
Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]). So all I do is
add
the field 07Jan into my report. The problem am having is I like to replace
all the 0.00 totals with "-". I try to do IIF(Nz([07Jan]=0,"-",Nz([07Jan])
but I get an #Error in the repot. The only way I got to work is by using
a
text box and if I repeat the whole formula in the report as well by
saying:
IIF(Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4])=0,"-",Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]))
but I am defeating the point of using the query to calcuate my totals. I
am
sure there is a simple way to do it but can't get there

Help is always appreciated

Hadi



  #4  
Old July 20th, 2007, 07:14 PM posted to microsoft.public.access.reports
Klatuu
external usenet poster
 
Posts: 7,074
Default Replace zeros with "-" in reports

for starters, your formula is incorrect. You need to give the Nz function a
return value for Null values.

Nz([07Jan],0)=0,"-",Nz([07Jan],0)

But, I would do this. Make this the control source for the control on the
report:
=Nz([07Jan_1],0)+Nz([07Jan_2],0)+Nz([07Jan_3],0)+Nz([07Jan_4],0)

And use this in the format property of the control:
"#0.0;-#0.0;-"
It has 3 parts. First part is for positive numbers #0.0
Second part is for negative numbers -#0.0
Third part is for 0


--
Dave Hargis, Microsoft Access MVP


"Hadi" wrote:

Hello Experts,

I have a report that based on a query. The query adds up my monthly hours
for the people that work on the project and the report displays the result.
my formula in the query to calculate total forJanuary for example is 07Jan:
Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]). So all I do is add
the field 07Jan into my report. The problem am having is I like to replace
all the 0.00 totals with "-". I try to do IIF(Nz([07Jan]=0,"-",Nz([07Jan])
but I get an #Error in the repot. The only way I got to work is by using a
text box and if I repeat the whole formula in the report as well by saying:
IIF(Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4])=0,"-",Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]))
but I am defeating the point of using the query to calcuate my totals. I am
sure there is a simple way to do it but can't get there

Help is always appreciated

Hadi

  #5  
Old July 20th, 2007, 07:44 PM posted to microsoft.public.access.reports
Klatuu
external usenet poster
 
Posts: 7,074
Default Replace zeros with "-" in reports

Format(SomeNumber, "0.0%")
--
Dave Hargis, Microsoft Access MVP


"Hadi" wrote:

Wow that works great. Thanks

how about % type numbers, what is the correct format?

"Douglas J. Steele" wrote:

You could try using the Format property of the text box in which the
calculation is being displayed. Formats for numeric fields can have up to
four sections defined, with each section separated by semi-colons. The first
section is the format for positive numbers, the second section is the format
for negative numbers, the third section is the format for zero values, and
the fourth section is the format for Null values.

You could use something like

#.0;(#.0);"-";"-"


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Hadi" wrote in message
...
Hello Experts,

I have a report that based on a query. The query adds up my monthly hours
for the people that work on the project and the report displays the
result.
my formula in the query to calculate total forJanuary for example is
07Jan:
Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]). So all I do is
add
the field 07Jan into my report. The problem am having is I like to replace
all the 0.00 totals with "-". I try to do IIF(Nz([07Jan]=0,"-",Nz([07Jan])
but I get an #Error in the repot. The only way I got to work is by using
a
text box and if I repeat the whole formula in the report as well by
saying:
IIF(Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4])=0,"-",Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]))
but I am defeating the point of using the query to calcuate my totals. I
am
sure there is a simple way to do it but can't get there

Help is always appreciated

Hadi




  #6  
Old July 20th, 2007, 08:04 PM posted to microsoft.public.access.reports
hadi
external usenet poster
 
Posts: 44
Default Replace zeros with "-" in reports

Wow that works great. Thanks

how about % type numbers, what is the correct format?

"Douglas J. Steele" wrote:

You could try using the Format property of the text box in which the
calculation is being displayed. Formats for numeric fields can have up to
four sections defined, with each section separated by semi-colons. The first
section is the format for positive numbers, the second section is the format
for negative numbers, the third section is the format for zero values, and
the fourth section is the format for Null values.

You could use something like

#.0;(#.0);"-";"-"


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Hadi" wrote in message
...
Hello Experts,

I have a report that based on a query. The query adds up my monthly hours
for the people that work on the project and the report displays the
result.
my formula in the query to calculate total forJanuary for example is
07Jan:
Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]). So all I do is
add
the field 07Jan into my report. The problem am having is I like to replace
all the 0.00 totals with "-". I try to do IIF(Nz([07Jan]=0,"-",Nz([07Jan])
but I get an #Error in the repot. The only way I got to work is by using
a
text box and if I repeat the whole formula in the report as well by
saying:
IIF(Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4])=0,"-",Nz([07Jan_1])+Nz([07Jan_2])+Nz([07Jan_3])+Nz([07Jan_4]))
but I am defeating the point of using the query to calcuate my totals. I
am
sure there is a simple way to do it but can't get there

Help is always appreciated

Hadi




 




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 07:27 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.