Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry S. Larry S. is offline
external usenet poster
 
Posts: 5
Default Using if fields in mail merge to ignore empty fields

I am using Access 2002 to set up a mail merge letter and envelope. Some of
the records in my Access database don't have all of the name and address
fields. In older versions of Access that I used in the past, I was able to
use an "IF" field to to essentially say that if the field existed to add a
space after it, otherwise don't add the space. i.e. one record has a
"middlename" field, another doesn't. I don't want the one without the
middlename field to have two spaces between first and last name, which would
happen if I hard coded the spaces in. Same thing if a record doesn't have a
salutation field, or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can it be
done both ways? If so, I would appreciate getting info on both, and the
reasons to prefer one or the other. Thanks.



--
Larry S
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Using if fields in mail merge to ignore empty fields

You can use either an If() function in an Access query or an
If...then...Else... field in the mail merge main document.

For the latter the construction would be

{ MERGEFIELD firstname } { IF { MERGEFIELD middleinitial } "" "{
MERGEFIELD middleinitial } { MERGEFIELD lastname }" "{ MERGEFIELD
lastname }" }

However, I would always manipulate the data in the database.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
I am using Access 2002 to set up a mail merge letter and envelope. Some of
the records in my Access database don't have all of the name and address
fields. In older versions of Access that I used in the past, I was able
to
use an "IF" field to to essentially say that if the field existed to add a
space after it, otherwise don't add the space. i.e. one record has a
"middlename" field, another doesn't. I don't want the one without the
middlename field to have two spaces between first and last name, which
would
happen if I hard coded the spaces in. Same thing if a record doesn't have
a
salutation field, or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can it be
done both ways? If so, I would appreciate getting info on both, and the
reasons to prefer one or the other. Thanks.



--
Larry S



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Using if fields in mail merge to ignore empty fields

You can use conditional fields exactly as before.
{IF {Mergefield Fieldname} "" "{Mergefield Fieldname} "}
will add the field and a following space if the field has content. Otherwise
it does nothing.

--

Graham Mayor - Word MVP

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


Larry S. wrote:
I am using Access 2002 to set up a mail merge letter and envelope.
Some of the records in my Access database don't have all of the name
and address fields. In older versions of Access that I used in the
past, I was able to use an "IF" field to to essentially say that if
the field existed to add a space after it, otherwise don't add the
space. i.e. one record has a "middlename" field, another doesn't. I
don't want the one without the middlename field to have two spaces
between first and last name, which would happen if I hard coded the
spaces in. Same thing if a record doesn't have a salutation field,
or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can
it be done both ways? If so, I would appreciate getting info on
both, and the reasons to prefer one or the other. Thanks.



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry S. Larry S. is offline
external usenet poster
 
Posts: 5
Default Using if fields in mail merge to ignore empty fields

Hi Doug,

Thanks for your answer. How can I get two different entries as a response
to the IF statement. The way I want to use this is that if the middle name
exists, to print the middle name THEN ADD A SPACE. In other words to insert
both a field and selected text after that field. I can also see using this
to add things like commas and periods, depending on the context.

The WORD help files seem to have limited information on these kind of
issues. Is there a site that I can use as a resource that would give me full
help files on things like conditional statements, switches, etc? If so, what
would you recommend?

The idea of using the database queries to manipulate the data sounds good,
but I'm not sure just how to do that. I used to work with SQL some years
ago, but frankly have forgotten much of what I knew. Are there options in
Access that would let me do this directly, or do I need to write these
statements directly into the SQL ? In either case, and clues you can give me
as to how to do it and where to find more info for what I'm not sure of will
be helpful.

Thanks.
--
Larry S


"Doug Robbins - Word MVP" wrote:

You can use either an If() function in an Access query or an
If...then...Else... field in the mail merge main document.

For the latter the construction would be

{ MERGEFIELD firstname } { IF { MERGEFIELD middleinitial } "" "{
MERGEFIELD middleinitial } { MERGEFIELD lastname }" "{ MERGEFIELD
lastname }" }

However, I would always manipulate the data in the database.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
I am using Access 2002 to set up a mail merge letter and envelope. Some of
the records in my Access database don't have all of the name and address
fields. In older versions of Access that I used in the past, I was able
to
use an "IF" field to to essentially say that if the field existed to add a
space after it, otherwise don't add the space. i.e. one record has a
"middlename" field, another doesn't. I don't want the one without the
middlename field to have two spaces between first and last name, which
would
happen if I hard coded the spaces in. Same thing if a record doesn't have
a
salutation field, or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can it be
done both ways? If so, I would appreciate getting info on both, and the
reasons to prefer one or the other. Thanks.



--
Larry S




  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry S. Larry S. is offline
external usenet poster
 
Posts: 5
Default Using if fields in mail merge to ignore empty fields


--
Larry S
Graham,

Thanks for getting back to me. From the way you wrote out the "then"
clause, it looks like you've added the space by including a space between the
closing bracket of Mergefield, and the ending quote. Is this correct? Can I
add punctuation such as a comma the same way, by including it between the
bracket and the quote? Can I include more than one field by including them
both between the quotes, and possibly add a space or punctuation between them
by writing "{Mergefield Fieldname1}, {Mergefield Fieldname2}" ?

Can you refer me to an online resource that would give me this kind of
information, so I can look it up myself as needed? Also, is there a way to
add spaces with switches? If so, which would you recommend?

Thanks.

Larry

"Graham Mayor" wrote:

You can use conditional fields exactly as before.
{IF {Mergefield Fieldname} "" "{Mergefield Fieldname} "}
will add the field and a following space if the field has content. Otherwise
it does nothing.

--

Graham Mayor - Word MVP

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


Larry S. wrote:
I am using Access 2002 to set up a mail merge letter and envelope.
Some of the records in my Access database don't have all of the name
and address fields. In older versions of Access that I used in the
past, I was able to use an "IF" field to to essentially say that if
the field existed to add a space after it, otherwise don't add the
space. i.e. one record has a "middlename" field, another doesn't. I
don't want the one without the middlename field to have two spaces
between first and last name, which would happen if I hard coded the
spaces in. Same thing if a record doesn't have a salutation field,
or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can
it be done both ways? If so, I would appreciate getting info on
both, and the reasons to prefer one or the other. Thanks.






  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Using if fields in mail merge to ignore empty fields

You can add just about anything you want between the quotes including
punctuation, fields, graphics etc. You are simply telling Word to insert
that lot if the field has content. You may find
http://www.gmayor.com/formatting_word_fields.htm useful.

--

Graham Mayor - Word MVP

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



Larry S. wrote:

You can use conditional fields exactly as before.
{IF {Mergefield Fieldname} "" "{Mergefield Fieldname} "}
will add the field and a following space if the field has content.
Otherwise it does nothing.

--

Graham Mayor - Word MVP

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


Larry S. wrote:
I am using Access 2002 to set up a mail merge letter and envelope.
Some of the records in my Access database don't have all of the name
and address fields. In older versions of Access that I used in the
past, I was able to use an "IF" field to to essentially say that if
the field existed to add a space after it, otherwise don't add the
space. i.e. one record has a "middlename" field, another doesn't.
I don't want the one without the middlename field to have two spaces
between first and last name, which would happen if I hard coded the
spaces in. Same thing if a record doesn't have a salutation field,
or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can
it be done both ways? If so, I would appreciate getting info on
both, and the reasons to prefer one or the other. Thanks.



  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry S. Larry S. is offline
external usenet poster
 
Posts: 5
Default Using if fields in mail merge to ignore empty fields

Hi Graham,

Thanks for your suggestions. I checked out your website, and it is
obviously a fantastic resource! For those of us with just enough computer
knowledge to be dangerous , It's sure great to have people like you
around.
--
Larry S


"Graham Mayor" wrote:

You can add just about anything you want between the quotes including
punctuation, fields, graphics etc. You are simply telling Word to insert
that lot if the field has content. You may find
http://www.gmayor.com/formatting_word_fields.htm useful.

--

Graham Mayor - Word MVP

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



Larry S. wrote:

You can use conditional fields exactly as before.
{IF {Mergefield Fieldname} "" "{Mergefield Fieldname} "}
will add the field and a following space if the field has content.
Otherwise it does nothing.

--

Graham Mayor - Word MVP

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


Larry S. wrote:
I am using Access 2002 to set up a mail merge letter and envelope.
Some of the records in my Access database don't have all of the name
and address fields. In older versions of Access that I used in the
past, I was able to use an "IF" field to to essentially say that if
the field existed to add a space after it, otherwise don't add the
space. i.e. one record has a "middlename" field, another doesn't.
I don't want the one without the middlename field to have two spaces
between first and last name, which would happen if I hard coded the
spaces in. Same thing if a record doesn't have a salutation field,
or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can
it be done both ways? If so, I would appreciate getting info on
both, and the reasons to prefer one or the other. Thanks.




  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Using if fields in mail merge to ignore empty fields

Use the field construction that I gave you. You must use Ctrl+F9 to insert
each pair of field delimiters and just change the names of the mergefields
that I used in the example to the names of the fields in your data source.
Use Alt+F9 to toggle the display of the field codes.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
Hi Doug,

Thanks for your answer. How can I get two different entries as a response
to the IF statement. The way I want to use this is that if the middle
name
exists, to print the middle name THEN ADD A SPACE. In other words to
insert
both a field and selected text after that field. I can also see using
this
to add things like commas and periods, depending on the context.

The WORD help files seem to have limited information on these kind of
issues. Is there a site that I can use as a resource that would give me
full
help files on things like conditional statements, switches, etc? If so,
what
would you recommend?

The idea of using the database queries to manipulate the data sounds good,
but I'm not sure just how to do that. I used to work with SQL some years
ago, but frankly have forgotten much of what I knew. Are there options in
Access that would let me do this directly, or do I need to write these
statements directly into the SQL ? In either case, and clues you can give
me
as to how to do it and where to find more info for what I'm not sure of
will
be helpful.

Thanks.
--
Larry S


"Doug Robbins - Word MVP" wrote:

You can use either an If() function in an Access query or an
If...then...Else... field in the mail merge main document.

For the latter the construction would be

{ MERGEFIELD firstname } { IF { MERGEFIELD middleinitial } "" "{
MERGEFIELD middleinitial } { MERGEFIELD lastname }" "{ MERGEFIELD
lastname }" }

However, I would always manipulate the data in the database.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
I am using Access 2002 to set up a mail merge letter and envelope. Some
of
the records in my Access database don't have all of the name and
address
fields. In older versions of Access that I used in the past, I was
able
to
use an "IF" field to to essentially say that if the field existed to
add a
space after it, otherwise don't add the space. i.e. one record has a
"middlename" field, another doesn't. I don't want the one without the
middlename field to have two spaces between first and last name, which
would
happen if I hard coded the spaces in. Same thing if a record doesn't
have
a
salutation field, or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can it
be
done both ways? If so, I would appreciate getting info on both, and
the
reasons to prefer one or the other. Thanks.



--
Larry S






  #9   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Larry S. Larry S. is offline
external usenet poster
 
Posts: 5
Default Using if fields in mail merge to ignore empty fields

OK, Thanks. Any suggestions on how to make the changes in the database if I
want to go that route? Would I do that in SQL?
--
Larry S


"Doug Robbins - Word MVP" wrote:

Use the field construction that I gave you. You must use Ctrl+F9 to insert
each pair of field delimiters and just change the names of the mergefields
that I used in the example to the names of the fields in your data source.
Use Alt+F9 to toggle the display of the field codes.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
Hi Doug,

Thanks for your answer. How can I get two different entries as a response
to the IF statement. The way I want to use this is that if the middle
name
exists, to print the middle name THEN ADD A SPACE. In other words to
insert
both a field and selected text after that field. I can also see using
this
to add things like commas and periods, depending on the context.

The WORD help files seem to have limited information on these kind of
issues. Is there a site that I can use as a resource that would give me
full
help files on things like conditional statements, switches, etc? If so,
what
would you recommend?

The idea of using the database queries to manipulate the data sounds good,
but I'm not sure just how to do that. I used to work with SQL some years
ago, but frankly have forgotten much of what I knew. Are there options in
Access that would let me do this directly, or do I need to write these
statements directly into the SQL ? In either case, and clues you can give
me
as to how to do it and where to find more info for what I'm not sure of
will
be helpful.

Thanks.
--
Larry S


"Doug Robbins - Word MVP" wrote:

You can use either an If() function in an Access query or an
If...then...Else... field in the mail merge main document.

For the latter the construction would be

{ MERGEFIELD firstname } { IF { MERGEFIELD middleinitial } "" "{
MERGEFIELD middleinitial } { MERGEFIELD lastname }" "{ MERGEFIELD
lastname }" }

However, I would always manipulate the data in the database.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
I am using Access 2002 to set up a mail merge letter and envelope. Some
of
the records in my Access database don't have all of the name and
address
fields. In older versions of Access that I used in the past, I was
able
to
use an "IF" field to to essentially say that if the field existed to
add a
space after it, otherwise don't add the space. i.e. one record has a
"middlename" field, another doesn't. I don't want the one without the
middlename field to have two spaces between first and last name, which
would
happen if I hard coded the spaces in. Same thing if a record doesn't
have
a
salutation field, or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can it
be
done both ways? If so, I would appreciate getting info on both, and
the
reasons to prefer one or the other. Thanks.



--
Larry S






  #10   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Using if fields in mail merge to ignore empty fields

Use a query in Access.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
OK, Thanks. Any suggestions on how to make the changes in the database if
I
want to go that route? Would I do that in SQL?
--
Larry S


"Doug Robbins - Word MVP" wrote:

Use the field construction that I gave you. You must use Ctrl+F9 to
insert
each pair of field delimiters and just change the names of the
mergefields
that I used in the example to the names of the fields in your data
source.
Use Alt+F9 to toggle the display of the field codes.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
Hi Doug,

Thanks for your answer. How can I get two different entries as a
response
to the IF statement. The way I want to use this is that if the middle
name
exists, to print the middle name THEN ADD A SPACE. In other words to
insert
both a field and selected text after that field. I can also see using
this
to add things like commas and periods, depending on the context.

The WORD help files seem to have limited information on these kind of
issues. Is there a site that I can use as a resource that would give
me
full
help files on things like conditional statements, switches, etc? If
so,
what
would you recommend?

The idea of using the database queries to manipulate the data sounds
good,
but I'm not sure just how to do that. I used to work with SQL some
years
ago, but frankly have forgotten much of what I knew. Are there options
in
Access that would let me do this directly, or do I need to write these
statements directly into the SQL ? In either case, and clues you can
give
me
as to how to do it and where to find more info for what I'm not sure of
will
be helpful.

Thanks.
--
Larry S


"Doug Robbins - Word MVP" wrote:

You can use either an If() function in an Access query or an
If...then...Else... field in the mail merge main document.

For the latter the construction would be

{ MERGEFIELD firstname } { IF { MERGEFIELD middleinitial } "" "{
MERGEFIELD middleinitial } { MERGEFIELD lastname }" "{ MERGEFIELD
lastname }" }

However, I would always manipulate the data in the database.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Larry S." wrote in message
...
I am using Access 2002 to set up a mail merge letter and envelope.
Some
of
the records in my Access database don't have all of the name and
address
fields. In older versions of Access that I used in the past, I was
able
to
use an "IF" field to to essentially say that if the field existed to
add a
space after it, otherwise don't add the space. i.e. one record has
a
"middlename" field, another doesn't. I don't want the one without
the
middlename field to have two spaces between first and last name,
which
would
happen if I hard coded the spaces in. Same thing if a record
doesn't
have
a
salutation field, or perhaps a title field.

How can I use if messages and/or switches to best set this up? Can
it
be
done both ways? If so, I would appreciate getting info on both, and
the
reasons to prefer one or the other. Thanks.



--
Larry S








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
Mail Merge - removing excess fields [email protected] New Users 2 July 3rd 06 10:04 PM
How do I mail merge a form without losing the form fields when me. TGM Mailmerge 1 May 30th 06 12:11 PM
mail merge and text form fields Miss Su Mailmerge 1 February 4th 06 09:29 PM
Empty Mail Merge Fields Meggan Microsoft Word Help 1 January 13th 05 05:22 AM
Empty Mail Merge Fields Meggan Microsoft Word Help 0 January 13th 05 12:43 AM


All times are GMT +1. The time now is 07:48 AM.

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"