Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / October 2003

Tip: Looking for answers? Try searching our database.

IF fields

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George - 07 Oct 2003 19:36 GMT
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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.