conditional field

P

Paul Bishop

I cannot quite find the answer that I am looking for in previous postings. I
have a text form field, bookmarked as "positive", that takes numeric values.
Based on this field, on exit from this field I want to display another field,
(called pN) with the value 0 if "positive" contains 0, "1" if "positive"
contains 1, 2 or 3, "2" if "positive" contains 4 or more.
 
J

Jean-Guy Marcil

Paul Bishop was telling us:
Paul Bishop nous racontait que :
I cannot quite find the answer that I am looking for in previous
postings. I have a text form field, bookmarked as "positive", that
takes numeric values. Based on this field, on exit from this field I
want to display another field, (called pN) with the value 0 if
"positive" contains 0, "1" if "positive" contains 1, 2 or 3, "2" if
"positive" contains 4 or more.

Try this:

If IsNumeric(ActiveDocument.FormFields("positive").Result) Then
Select Case CLng(ActiveDocument.FormFields("positive").Result)
Case 0
ActiveDocument.FormFields("pN").Result = "0"
Case 1, 2, 3
ActiveDocument.FormFields("pN").Result = "1"
Case Is >= 4
ActiveDocument.FormFields("pN").Result = "2"
Case Else
GoTo NotValid
End Select
Else
GoTo NotValid
End If

Exit Sub

NotValid:
MsgBox "The value of the ""POsitive"" field is invalid.", _
vbExclamation, "Wrong data"



--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
P

Paul Bishop

Thanks. That seems to work wonderfully. I also want to make a Text Form
Field dependent on the selected item from a Drop Down Form Field, but I think
the answers are already in previous threads. If I cannot make it work, I
will ask again.
 
G

Graham Mayor

At the location you want the field result 'pN' - Insert the following

{ IF{ REF Positive } = 0 "0" "{ IF{ REF Postive} >= 1 "{ IF{ REF Positive }
< 4 "1" "2" } }"}

Check the 'calculate on exit check box of formfield 'positive'.

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