I'm having some problems using the IF field in conjuction
with a checkbox form field. What I am tring to do is setup
a checkbox called usepgh001, that when checked, the IF
field would referance to a bookmark called pgh001. This is
what i have tried to do:
{ IF usepgh001 = U { REF pgh001 \* MERGEFORMAT }"" \*
MERGEFORMAT }
where i have typed in place of the U, True, "True", 1, X,
and other things.
I could not get this to work. Can anyone tell me why?
Peter Jamieson - 08 Oct 2003 08:28 GMT
Unfortunately even if you use
{ IF { REF check1 } = whatever "true" "false" }
you cannot test the value of the checkbox field because it always returns
the same null result however it is checked.
You could achieve what you want using a VBA Exit macro (i.e. specify an Exit
macro in the properties of the check box field) to insert the result
directly, or
using it to set up (say) a custom property or Word variable that you then
display.
e.g.
Sub processusepgh001a()
With ActiveDocument
On Error Resume Next
.CustomDocumentProperties("usepgh001").Delete
Err.Clear
On Error GoTo 0
.CustomDocumentProperties.Add _
Name:="usepgh001", _
LinkToContent:=False, _
Value:=ActiveDocument.FormFields("usepgh001").Result, _
Type:=msoPropertyTypeString
End With
End Sub
then use
{ IF { DOCPROPERTY "usepgh001" } = 1 "{ REF pgh001 }" "" }
Beware of the following approach, which looks simpler:
Sub processusepgh001a()
With ActiveDocument
On Error Resume Next
.CustomDocumentProperties("usepgh001").Delete
Err.Clear
On Error GoTo 0
.CustomDocumentProperties.Add _
Name:="usepgh001", _
LinkToContent:=False, _
Value:=ActiveDocument.FormFields("pgh001").Result, _
Type:=msoPropertyTypeString
End With
End Sub
and just use { DOCPROPERTY usepgh001 }
because it relies on the result of pgh001 being finalised at the time
usepgh001 is set, which may not be the case.
--
Peter Jamieson
MS Word MVP
> I'm having some problems using the IF field in conjuction
> with a checkbox form field. What I am tring to do is setup
[quoted text clipped - 9 lines]
>
> I could not get this to work. Can anyone tell me why?