Using IF function in Word

  • Thread starter Thread starter gbf5
  • Start date Start date
G

gbf5

I want to use the IF function to evaluate a field and act accordingly. IF
the field is blank return blank, IF the field is not blank multiply the same
field by another field. I can't seem to get this right any suggestions or
help you can give me would be greatly appreciated.

Thanks
 
What kind of field are you trying to evaluate? If it is a text form field,
you can use the bookmark that it creates; the bookmark name can be specified
in the Text Form Field Options dialog box, but by default Word uses Text1,
Text2, etc.

Also, in the Text Form Field Options dialog box, be sure to check the
"Calculate on exit" option.

What does "blank" mean? Again, if we are dealing with a text form field, an
un-filled field contains five spaces, so you could then use this
nested field:

{ IF { Text1 } = " " "" "{ = { Text1 } * { OtherBookmarkName }" }

To insert each pair of field delimiters, { }, press Ctrl+F9. Type the code.
When you are done, press F9 to update. Use Alt+F9 to show/hide field codes.

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 
Assuming the fields you are talkinf about are all fields in a mailmerge data
source, you would need something like

{ IF "{ MERGEFIELD myfield1 }" = "" "" "{ ={MERGEFIELD myfield1 }*{
MERGEFIELD myfield2 } }" }

All the {} have to be the special field code braces that you can insert
using ctrl-F9. Not all the spacing and quoting is compulsory, but if you
don't follow it, don't be surprised if the fields don't always work as you
expect

If the field names have spaces or other troublemaking characters in them,
you have to quote the name, e.g.

{ IF "{ MERGEFIELD "myfield 1" }" = "" "" "{ = {MERGEFIELD "myfield 1" }*{
MERGEFIELD "myfield 2" } }" }
 
Thanks, got it working now.

Peter Jamieson said:
Assuming the fields you are talkinf about are all fields in a mailmerge data
source, you would need something like

{ IF "{ MERGEFIELD myfield1 }" = "" "" "{ ={MERGEFIELD myfield1 }*{
MERGEFIELD myfield2 } }" }

All the {} have to be the special field code braces that you can insert
using ctrl-F9. Not all the spacing and quoting is compulsory, but if you
don't follow it, don't be surprised if the fields don't always work as you
expect

If the field names have spaces or other troublemaking characters in them,
you have to quote the name, e.g.

{ IF "{ MERGEFIELD "myfield 1" }" = "" "" "{ = {MERGEFIELD "myfield 1" }*{
MERGEFIELD "myfield 2" } }" }
 
Thanks, got it working now.

Stefan Blom said:
What kind of field are you trying to evaluate? If it is a text form field,
you can use the bookmark that it creates; the bookmark name can be specified
in the Text Form Field Options dialog box, but by default Word uses Text1,
Text2, etc.

Also, in the Text Form Field Options dialog box, be sure to check the
"Calculate on exit" option.

What does "blank" mean? Again, if we are dealing with a text form field, an
un-filled field contains five spaces, so you could then use this
nested field:

{ IF { Text1 } = " " "" "{ = { Text1 } * { OtherBookmarkName }" }

To insert each pair of field delimiters, { }, press Ctrl+F9. Type the code.
When you are done, press F9 to update. Use Alt+F9 to show/hide field codes.

--
Stefan Blom
Microsoft Word MVP


in message
 

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

Back
Top