Toggle form field between U.S. dollars and Euros

L

Lenny

I have a finance form that my user would like to be able to show the entry as
either U.S. dollars or European Euros. Normally, the field would be set to
dollars and the format to reflect $x,xx.00. The Euro is formatted
differently. Can I use a check box or other device to affect the formatting
of the field?

Best regards... Lenny
 
G

Graham Mayor

Lenny said:
I have a finance form that my user would like to be able to show the
entry as either U.S. dollars or European Euros. Normally, the field
would be set to dollars and the format to reflect $x,xx.00. The Euro
is formatted differently. Can I use a check box or other device to
affect the formatting of the field?

Best regards... Lenny

One way you can do this is with a checkbox field and a macro run on exit
from that checkbox. The checkbox must be after the numeric input field(s).
The field that will represent the number must be formatted with a unicode
font that has the Euro symbol. In the example macro, the numeric field is
Text1 and the Checkbox field is Check1. The macro reads the numeric entry in
Text1 (***which should be a regular text field***) and adds the Dollar or
Euro sign.

If there are calculations involved with the content of the form field(s),
they will have to be performed in the macro and the result field(s) updated
accordingly, as a text field with a leading text character will not work in
a calculation. The basic code example is:

Sub CashFormat()
Dim sValue As String
sValue = ActiveDocument.FormFields("Text1").Result
If InStr(1, sValue, "$") Then
sValue = replace(sValue, "$", "")
End If
If InStr(1, sValue, "?") Then
sValue = replace(sValue, "?", "")
End If

If ActiveDocument.FormFields("Check1").CheckBox.Value = True Then
ActiveDocument.FormFields("Text1").Result = "$" & sValue
Else
ActiveDocument.FormFields("Text1").Result = "?" & sValue
End If
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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