Hiding zero values

D

DomMar

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

Greg Maxey

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

DomMar

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?
 
G

Greg Maxey

DomMar.

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

{ =(Text1+Text2) \# "$,#.00;-$,#.00; " }
 
D

DomMar

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
 
G

Greg Maxey

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

DomMar

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
 
G

Greg Maxey

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
 
D

DomMar

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.
 

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

Top