IF fields

G

George

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

Peter Jamieson

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.
 

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