IF/Then variable in form?

A

Angyl

Anyone know how to write the code so that IF a # in a field (call it Premium)
is LESS THAN $50. THEN this field = that field plus whatever it takes to be
$50...

otherwise, the field is Zero?
 
G

Greg Maxey

A bit difficult to tell exactly what you want, but this provides the
basic code:

Sub OnExitPremium()
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
If Val(oFld("Premium").Result) < 50 Then
oFld("ThisField").Result = Val(oFld("Premium").Result) + (50 -
Val(oFld("Premium").Result))
'or OFld("ThisField").Result = 50
Else
oFld("ThisField").Result = 0
End If
End Sub
 
A

Angyl

Very nice, as usual, Greg!

Greg Maxey said:
A bit difficult to tell exactly what you want, but this provides the
basic code:

Sub OnExitPremium()
Dim oFld As FormFields
Set oFld = ActiveDocument.FormFields
If Val(oFld("Premium").Result) < 50 Then
oFld("ThisField").Result = Val(oFld("Premium").Result) + (50 -
Val(oFld("Premium").Result))
'or OFld("ThisField").Result = 50
Else
oFld("ThisField").Result = 0
End If
End Sub
 

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