Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
HelenC HelenC is offline
external usenet poster
 
Posts: 2
Default Word: IF statement to merge a field only if another Field is popul

There are three fields SUBJECT_CODE, STUDENT_NAME, TUTOR_NAME. In all cases,
the Subject_Code field will be populated, but either the Student_Name field
or the Tutor_Name field (never both). I want to put in a command to only
merge the Subject_Code field IF the Tutor_Name field is populated. I have
used the help function and found the example below, which I have tried to
adapt to say IF mergefield Tutor_Name is not blank merge mergefield
Subject_Code or if false put nothing, but it didn't work.

"If the Company data field for a data record contains any information €” that
is, if the field is not blank €” Word prints text from the CompanyAddress
field. Otherwise, Word prints text from the HomeAddress field."

{ IF { MERGEFIELD Company } " " "{ MERGEFIELD CompanyAddress }" "{
MERGEFIELD HomeAddress }" }

This is what I put:
{ IF { MERGEFIELD TM_Name} "{MERGEFIELD Socrates_Subject_Code }" " ""}

But no luck. I don't really have any knowledge of programming, everything I
know (which is little) is self taught and done by trial and error! I'd be
very grateful for some help. If I can't solve this, I'm going to have to
redesign my database, which I would rather not do.

Thank you in advance.


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default IF statement to merge a field only if another Field is popul

{IF{Mergefield Tutor_Name} "" "{Mergefield Subject_Code}"}
should work

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


HelenC wrote:
There are three fields SUBJECT_CODE, STUDENT_NAME, TUTOR_NAME. In
all cases, the Subject_Code field will be populated, but either the
Student_Name field or the Tutor_Name field (never both). I want to
put in a command to only merge the Subject_Code field IF the
Tutor_Name field is populated. I have used the help function and
found the example below, which I have tried to adapt to say IF
mergefield Tutor_Name is not blank merge mergefield Subject_Code or
if false put nothing, but it didn't work.

"If the Company data field for a data record contains any information
- that is, if the field is not blank - Word prints text from the
CompanyAddress field. Otherwise, Word prints text from the
HomeAddress field."

{ IF { MERGEFIELD Company } " " "{ MERGEFIELD CompanyAddress }" "{
MERGEFIELD HomeAddress }" }

This is what I put:
{ IF { MERGEFIELD TM_Name} "{MERGEFIELD Socrates_Subject_Code }" "
""}

But no luck. I don't really have any knowledge of programming,
everything I know (which is little) is self taught and done by trial
and error! I'd be very grateful for some help. If I can't solve
this, I'm going to have to redesign my database, which I would rather
not do.

Thank you in advance.



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
HelenC HelenC is offline
external usenet poster
 
Posts: 2
Default IF statement to merge a field only if another Field is popul

It worked! Thank you so much.

"Graham Mayor" wrote:

{IF{Mergefield Tutor_Name} "" "{Mergefield Subject_Code}"}
should work

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


HelenC wrote:
There are three fields SUBJECT_CODE, STUDENT_NAME, TUTOR_NAME. In
all cases, the Subject_Code field will be populated, but either the
Student_Name field or the Tutor_Name field (never both). I want to
put in a command to only merge the Subject_Code field IF the
Tutor_Name field is populated. I have used the help function and
found the example below, which I have tried to adapt to say IF
mergefield Tutor_Name is not blank merge mergefield Subject_Code or
if false put nothing, but it didn't work.

"If the Company data field for a data record contains any information
- that is, if the field is not blank - Word prints text from the
CompanyAddress field. Otherwise, Word prints text from the
HomeAddress field."

{ IF { MERGEFIELD Company } " " "{ MERGEFIELD CompanyAddress }" "{
MERGEFIELD HomeAddress }" }

This is what I put:
{ IF { MERGEFIELD TM_Name} "{MERGEFIELD Socrates_Subject_Code }" "
""}

But no luck. I don't really have any knowledge of programming,
everything I know (which is little) is self taught and done by trial
and error! I'd be very grateful for some help. If I can't solve
this, I'm going to have to redesign my database, which I would rather
not do.

Thank you in advance.




  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default IF statement to merge a field only if another Field is popul

You are welcome.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


HelenC wrote:
It worked! Thank you so much.

"Graham Mayor" wrote:

{IF{Mergefield Tutor_Name} "" "{Mergefield Subject_Code}"}
should work

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


HelenC wrote:
There are three fields SUBJECT_CODE, STUDENT_NAME, TUTOR_NAME. In
all cases, the Subject_Code field will be populated, but either the
Student_Name field or the Tutor_Name field (never both). I want to
put in a command to only merge the Subject_Code field IF the
Tutor_Name field is populated. I have used the help function and
found the example below, which I have tried to adapt to say IF
mergefield Tutor_Name is not blank merge mergefield Subject_Code or
if false put nothing, but it didn't work.

"If the Company data field for a data record contains any
information - that is, if the field is not blank - Word prints text
from the CompanyAddress field. Otherwise, Word prints text from the
HomeAddress field."

{ IF { MERGEFIELD Company } " " "{ MERGEFIELD CompanyAddress }"
"{ MERGEFIELD HomeAddress }" }

This is what I put:
{ IF { MERGEFIELD TM_Name} "{MERGEFIELD Socrates_Subject_Code }"
" ""}

But no luck. I don't really have any knowledge of programming,
everything I know (which is little) is self taught and done by trial
and error! I'd be very grateful for some help. If I can't solve
this, I'm going to have to redesign my database, which I would
rather not do.

Thank you in advance.



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detach or change SQL data source for Word template, and other Qs SJMac Mailmerge 6 July 27th 06 10:12 AM
I am having difficulty with deleting headers and footers LHD New Users 5 July 24th 06 01:44 AM
Change paper size; Word changes to invalid margins OhioTech New Users 10 July 6th 06 02:00 PM
Format Fractions in Mail Merge. John McGhie [MVP - Word and Word Macintosh] Mailmerge 4 March 22nd 06 08:55 AM
WP merge file to Word sstires Tables 4 February 14th 06 06:26 PM


All times are GMT +1. The time now is 11:37 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"