Recent Feedback
Ask a Microsoft Word Question>I've created a form including monetary calculations, using formfields. I need all fields to remain blank until the user has filled them in or they show the end result of a calculation based on the user's entry. Currently, an otherwise blank form has several result fields that show $0.00. I don't mind the dollar symbol, but the actual numerals are a problem in case the user needs to print the form and fill it out, rather than filling it out online.
Already Tried: I was advised to use a nymeric picture switch (\#). The suggestion was to put \# "$0.00,$0.00," in a formula field, or to use the same format wihtout the switch in the Number Format box in the Text Form Field Options screen. Using the second option (and trying a number of variations), I still end up with zeros, miscellaneous characters (, " .), a result displayed incorrectly as to the placement of the decimal point or a blank field.
My name isXXXXX and I am a certified Microsoft Word Expert affiliated with JustAnswers. Thank you for giving me the opportunity to assist you with your Word question.
Based on the way numerical fields and calculation fields work one option (if you want to remain with formfields) is to use formatted numerical fields for your variables using the following numerical format and leave the defualt numbe field blank:
$#,##0.00;($#,##0.00);
and use a plain text field (with fill in enabled unchecked) for the result. You would need to assign the following macro to run on exit from your variable field.
Sub SumOnExit()
Dim lngA As Long, lngB As Long, lngResult As Long
On Error Resume Next
lngA = CLng(ActiveDocument.FormFields("Text1").Result)
If Err.Number <> 0 Then lngA = 0
Err.Clear
lngB = CLng(ActiveDocument.FormFields("Text2").Result)
If Err.Number <> 0 Then lngB = 0
On Error GoTo 0
lngResult = lngA + lngB
ActiveDocument.FormFields("Text3").Result = FormatCurrency(lngResult)
If ActiveDocument.FormFields("Text1").Result = "" Then
ActiveDocument.FormFields("Text2").Result = ""
ActiveDocument.FormFields("Text3").Result = ""
End If
End Sub
As an alternative you could leave the form as it is and offer you users to the option to clear all fields including the zeros before printing using this procedure:Sub ClearZeroes()Dim oFF As FormFieldFor Each oFF In ActiveDocument.FormFields oFF.Result = ""NextEnd Sub
For help installing and using this macro see: http://www.gmayor.com/installing_macro.htm
Experience: Microsoft Word Most Valuable Professional (6 years)