Hiding zero values

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to have a calculation field in a form show as blank (spaces) when the
value is zero.
 
DomMar,

You can use a regulare formula field (vice calculation field) with a numeric
switch to hide the zero.

Example. Say you have Text1 and Text2 as the varialbles. Set both to
calculate on exit. Enter the following formula field.

{ =(Text1+Text1) \# "#;-#; " }

Note the field braces { } are entered with CTRL+F9. Once you have the
field entered then toggle the code and protect the form.
 
I'm sorry I was not clearer. The numeric format for the field includes a $ as
in
$#,##0.00;($#,##0.00). I tried using all # but the $ showed when the field
was zero. Is there a macro that I can use to change the format when the value
is zero?
 
DomMar.

Again you don't need a macro. A numeric switch will work fine:

{ =(Text1+Text2) \# "$,#.00;-$,#.00; " }
 
I tried to use Ctrl+F9 but it could not be entered. I tried with both a
calculation field and a formula field. Neither dialog box accepts ctrl+F9. My
document has a macro which will update all fields in document. I also tried
using keyboard {} but they did not work.

Regards,

DomMar
 
DomMar,

Forget the calculation field. Unprotect the document and use CTRL+F9 to
create a set of field code delimiters { } type the formula and format
switch directly inside the delimiters. Select the field and toggle the
code. Ensure both (or all) variable formfields are set to "calculate on
exit." Reprotect the form.
 
Greg,

Thank you I finally got it. Is there a way I can do the same for an
enterable numeric text field. Hrs. * Rate = Amt. Amt was the field you
pounded into my dense head. I'd like to do the same for Rate which is
enterable.

Regards,

DomMar
 
DomMar,

All I can suggest is an on exit macro to set the value to " " if the value
on exit is "0"

Sub Test()
If ActiveDocument.FormFields("Text2").Result = "0" Then
ActiveDocument.FormFields("Text2").Result = " "
End If

End Sub
 
Thanks you have been very Helpful.

Greg Maxey said:
DomMar,

All I can suggest is an on exit macro to set the value to " " if the value
on exit is "0"

Sub Test()
If ActiveDocument.FormFields("Text2").Result = "0" Then
ActiveDocument.FormFields("Text2").Result = " "
End If

End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
 
Back
Top