Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] clive.ming@hotmail.co.uk is offline
external usenet poster
 
Posts: 5
Default Mail merge .. . If Then Else

Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason doesnt
work and even when the condition is met it does not print @. As part
of the testing i have printed to screen Value X to confirm it contains
the data for the condition to be met but it doesnt write the @.

{ IF { MERGEFIELD PatientCode } = "XX" "@" "" }

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] clive.ming@hotmail.co.uk is offline
external usenet poster
 
Posts: 5
Default Mail merge .. . If Then Else

On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason doesnt
work and even when the condition is met it does not print @. As part
of the testing i have printed to screen Value X to confirm it contains
the data for the condition to be met but it doesnt write the @.

{ IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.

  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail merge .. . If Then Else

1. Are all the {} the special field code braces that you can insert using
ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.

{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }

Peter Jamieson
wrote in message
oups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason doesnt
work and even when the condition is met it does not print @. As part
of the testing i have printed to screen Value X to confirm it contains
the data for the condition to be met but it doesnt write the @.

{ IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Mail merge .. . If Then Else

And do test the result of {Mergefield PatientCode} without a condition to
ensure it reproduces exactly what you think it should reproduce. Try also

{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP

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


Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can insert
using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.

{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }

Peter Jamieson
wrote in message
oups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason
doesnt work and even when the condition is met it does not print @.
As part of the testing i have printed to screen Value X to confirm
it contains the data for the condition to be met but it doesnt
write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] clive.ming@hotmail.co.uk is offline
external usenet poster
 
Posts: 5
Default Mail merge .. . If Then Else

On 8 Feb, 16:15, "Graham Mayor" wrote:
And do test the result of {Mergefield PatientCode} without a condition to
ensure it reproduces exactly what you think it should reproduce. Try also

{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org




Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can insert
using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.


{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }


Peter Jamieson
wrote in message
roups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason
doesnt work and even when the condition is met it does not print @.
As part of the testing i have printed to screen Value X to confirm
it contains the data for the condition to be met but it doesnt
write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.- Hide quoted text -


- Show quoted text -


Hi - thanks for your suggestions - i cant try them at the moment as
production is down . With regards word mail merge i dont have any
exeperience apart from the hour or so that i have spent looking at
this issue (although i have numerous years of development experience -
somewhat offset by the fact i am now a manager ).

In one of the suggestions the code used \*Upper - i pressume that
there must be numerous other switches e.g. \*Lower etc. Is there a FAQ
that describes all these 'switches' - cant seem to find mention of
them Word Help.

Thanks in advance,

CM



  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail merge .. . If Then Else

They are in Word Help - if you can get to the table of contents in Word
2002/2003, look for

"Automating Tasks and Programmability"|"Field Types and Switches", then for
this specific topic look for "Field Reference"|"Switches" and for \*Upper
etc., "Format (\*) field switch".

If you're on another version of Word, things may be different.

Peter Jamieson
wrote in message
ups.com...
On 8 Feb, 16:15, "Graham Mayor" wrote:
And do test the result of {Mergefield PatientCode} without a condition to
ensure it reproduces exactly what you think it should reproduce. Try also

{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org




Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can insert
using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.


{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }


Peter Jamieson
wrote in message
roups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason
doesnt work and even when the condition is met it does not print @.
As part of the testing i have printed to screen Value X to confirm
it contains the data for the condition to be met but it doesnt
write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.- Hide quoted text -


- Show quoted text -


Hi - thanks for your suggestions - i cant try them at the moment as
production is down . With regards word mail merge i dont have any
exeperience apart from the hour or so that i have spent looking at
this issue (although i have numerous years of development experience -
somewhat offset by the fact i am now a manager ).

In one of the suggestions the code used \*Upper - i pressume that
there must be numerous other switches e.g. \*Lower etc. Is there a FAQ
that describes all these 'switches' - cant seem to find mention of
them Word Help.

Thanks in advance,

CM



  #7   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] clive.ming@hotmail.co.uk is offline
external usenet poster
 
Posts: 5
Default Mail merge .. . If Then Else

On 8 Feb, 16:55, wrote:
On 8 Feb, 16:15, "Graham Mayor" wrote:





And do test the result of {Mergefield PatientCode} without a condition to
ensure it reproduces exactly what you think it should reproduce. Try also


{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP


My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can insert
using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.


{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }


Peter Jamieson
wrote in message
roups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason
doesnt work and even when the condition is met it does not print @.
As part of the testing i have printed to screen Value X to confirm
it contains the data for the condition to be met but it doesnt
write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.- Hide quoted text -


- Show quoted text -


Hi - thanks for your suggestions - i cant try them at the moment as
production is down . With regards word mail merge i dont have any
exeperience apart from the hour or so that i have spent looking at
this issue (although i have numerous years of development experience -
somewhat offset by the fact i am now a manager ).

In one of the suggestions the code used \*Upper - i pressume that
there must be numerous other switches e.g. \*Lower etc. Is there a FAQ
that describes all these 'switches' - cant seem to find mention of
them Word Help.

Thanks in advance,

CM- Hide quoted text -

- Show quoted text -



Hi - just tried the suggested fix and it still doesnt work - the code
is below;

{ IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }

Any other suggestions - this is really frustrating because for all
intents and purposes it should work. I have tried using the same
logic with another merge field and it works fine - could there be
anything in particular with this field that might mean that the
condition is not being met?

Thanks in advance,

CM




  #8   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail merge .. . If Then Else

What is the result of { MERGEFIELD PatientCode } on its own?

Can you give some examples?

Peter Jamieson
wrote in message
oups.com...
On 8 Feb, 16:55, wrote:
On 8 Feb, 16:15, "Graham Mayor" wrote:





And do test the result of {Mergefield PatientCode} without a condition
to
ensure it reproduces exactly what you think it should reproduce. Try
also


{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP


My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can insert
using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.


{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }


Peter Jamieson
wrote in message
roups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason
doesnt work and even when the condition is met it does not print @.
As part of the testing i have printed to screen Value X to confirm
it contains the data for the condition to be met but it doesnt
write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have
been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.- Hide quoted text -


- Show quoted text -


Hi - thanks for your suggestions - i cant try them at the moment as
production is down . With regards word mail merge i dont have any
exeperience apart from the hour or so that i have spent looking at
this issue (although i have numerous years of development experience -
somewhat offset by the fact i am now a manager ).

In one of the suggestions the code used \*Upper - i pressume that
there must be numerous other switches e.g. \*Lower etc. Is there a FAQ
that describes all these 'switches' - cant seem to find mention of
them Word Help.

Thanks in advance,

CM- Hide quoted text -

- Show quoted text -



Hi - just tried the suggested fix and it still doesnt work - the code
is below;

{ IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }

Any other suggestions - this is really frustrating because for all
intents and purposes it should work. I have tried using the same
logic with another merge field and it works fine - could there be
anything in particular with this field that might mean that the
condition is not being met?

Thanks in advance,

CM






  #9   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 Mail merge .. . If Then Else

Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"

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

wrote in message
oups.com...
On 8 Feb, 16:55, wrote:
On 8 Feb, 16:15, "Graham Mayor" wrote:





And do test the result of {Mergefield PatientCode} without a condition
to
ensure it reproduces exactly what you think it should reproduce. Try
also


{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP


My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can insert
using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.


{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }


Peter Jamieson
wrote in message
roups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else conditional
statement with word mail merge. The logic that i am looking to
implement is if Value X = XX then print @ else print nothing. The
code is below. Now this seems very simple but for some reason
doesnt work and even when the condition is met it does not print @.
As part of the testing i have printed to screen Value X to confirm
it contains the data for the condition to be met but it doesnt
write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }


So the issue i have is that although the condition seems to have
been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a SQL
2000 SP3a database.- Hide quoted text -


- Show quoted text -


Hi - thanks for your suggestions - i cant try them at the moment as
production is down . With regards word mail merge i dont have any
exeperience apart from the hour or so that i have spent looking at
this issue (although i have numerous years of development experience -
somewhat offset by the fact i am now a manager ).

In one of the suggestions the code used \*Upper - i pressume that
there must be numerous other switches e.g. \*Lower etc. Is there a FAQ
that describes all these 'switches' - cant seem to find mention of
them Word Help.

Thanks in advance,

CM- Hide quoted text -

- Show quoted text -



Hi - just tried the suggested fix and it still doesnt work - the code
is below;

{ IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }

Any other suggestions - this is really frustrating because for all
intents and purposes it should work. I have tried using the same
logic with another merge field and it works fine - could there be
anything in particular with this field that might mean that the
condition is not being met?

Thanks in advance,

CM






  #10   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Mail merge .. . If Then Else

wrote:

Is there a FAQ
that describes all these 'switches' - cant seem to find mention of
them Word Help.


See
http://www.gmayor.com/formatting_word_fields.htm which covers all the
switches and their use and demonstrates some more involved procedures also.

--

Graham Mayor - Word MVP

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





  #11   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Mail merge .. . If Then Else

Hi Doug,

Since there's no spaces in the test condition or true/false results, the field works equally well with no quote characters:
{IF{MERGEFIELD PatientCode \*Upper} = XX @}

Another potential issue is whether the 'PatientCode' field contains exactly 'XX' - no more & no less. The OP said "As part of the
testing i have printed to screen Value X to confirm it contains the data for the condition to be met". That's only one 'X'. Or is
'Value X' the name of a/the field?

Cheers

--
macropod
[MVP - Microsoft Word]


"Doug Robbins - Word MVP" wrote in message ...
| Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"
|
| --
| 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
|
| wrote in message
| oups.com...
| On 8 Feb, 16:55, wrote:
| On 8 Feb, 16:15, "Graham Mayor" wrote:
|
|
|
|
|
| And do test the result of {Mergefield PatientCode} without a condition
| to
| ensure it reproduces exactly what you think it should reproduce. Try
| also
|
| { IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
| --
|
| Graham Mayor - Word MVP
|
| My web sitewww.gmayor.com
| Word MVP web sitehttp://word.mvps.org
|
|
| Peter Jamieson wrote:
| 1. Are all the {} the special field code braces that you can insert
| using ctrl-F9?
| 2. Is the value definitely XX and not xx, xX etc?
| 3. Try adding double quotes around the { MERGEFIELD } field, i.e.
|
| { IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }
|
| Peter Jamieson
| wrote in message
| roups.com...
| On 8 Feb, 15:33, wrote:
| Hi - i am having a few problems with the if then else conditional
| statement with word mail merge. The logic that i am looking to
| implement is if Value X = XX then print @ else print nothing. The
| code is below. Now this seems very simple but for some reason
| doesnt work and even when the condition is met it does not print @.
| As part of the testing i have printed to screen Value X to confirm
| it contains the data for the condition to be met but it doesnt
| write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }
|
| So the issue i have is that although the condition seems to have
| been
| met it does not execute the correct part of the conditional
| statement. The data being used for the mail merge comes from a SQL
| 2000 SP3a database.- Hide quoted text -
|
| - Show quoted text -
|
| Hi - thanks for your suggestions - i cant try them at the moment as
| production is down . With regards word mail merge i dont have any
| exeperience apart from the hour or so that i have spent looking at
| this issue (although i have numerous years of development experience -
| somewhat offset by the fact i am now a manager ).
|
| In one of the suggestions the code used \*Upper - i pressume that
| there must be numerous other switches e.g. \*Lower etc. Is there a FAQ
| that describes all these 'switches' - cant seem to find mention of
| them Word Help.
|
| Thanks in advance,
|
| CM- Hide quoted text -
|
| - Show quoted text -
|
|
| Hi - just tried the suggested fix and it still doesnt work - the code
| is below;
|
| { IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }
|
| Any other suggestions - this is really frustrating because for all
| intents and purposes it should work. I have tried using the same
| logic with another merge field and it works fine - could there be
| anything in particular with this field that might mean that the
| condition is not being met?
|
| Thanks in advance,
|
| CM
|
|
|
|
|
|


  #12   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Mail merge .. . If Then Else

Accepting what you say about quotes, I prefer always to use them as it makes
it so much simpler to see what the field construction actually does.

--

Graham Mayor - Word MVP

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



macropod wrote:
Hi Doug,

Since there's no spaces in the test condition or true/false results,
the field works equally well with no quote characters: {IF{MERGEFIELD
PatientCode \*Upper} = XX @}

Another potential issue is whether the 'PatientCode' field contains
exactly 'XX' - no more & no less. The OP said "As part of the testing
i have printed to screen Value X to confirm it contains the data for
the condition to be met". That's only one 'X'. Or is 'Value X' the
name of a/the field?

Cheers


"Doug Robbins - Word MVP" wrote in message
...
Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"

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

wrote in message
oups.com...
On 8 Feb, 16:55, wrote:
On 8 Feb, 16:15, "Graham Mayor" wrote:





And do test the result of {Mergefield PatientCode} without a
condition to
ensure it reproduces exactly what you think it should reproduce.
Try also

{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can
insert using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field, i.e.

{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }

Peter Jamieson
wrote in message
oups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else
conditional statement with word mail merge. The logic that i
am looking to implement is if Value X = XX then print @ else
print nothing. The code is below. Now this seems very simple
but for some reason doesnt work and even when the condition is
met it does not print @. As part of the testing i have printed
to screen Value X to confirm it contains the data for the
condition to be met but it doesnt write the @. { IF {
MERGEFIELD PatientCode } = "XX" "@" "" }

So the issue i have is that although the condition seems to have
been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from a
SQL 2000 SP3a database.- Hide quoted text -

- Show quoted text -

Hi - thanks for your suggestions - i cant try them at the moment as
production is down . With regards word mail merge i dont have
any exeperience apart from the hour or so that i have spent
looking at this issue (although i have numerous years of
development experience - somewhat offset by the fact i am now a
manager ).

In one of the suggestions the code used \*Upper - i pressume that
there must be numerous other switches e.g. \*Lower etc. Is there a
FAQ that describes all these 'switches' - cant seem to find
mention of them Word Help.

Thanks in advance,

CM- Hide quoted text -

- Show quoted text -


Hi - just tried the suggested fix and it still doesnt work - the
code is below;

{ IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }

Any other suggestions - this is really frustrating because for all
intents and purposes it should work. I have tried using the same
logic with another merge field and it works fine - could there be
anything in particular with this field that might mean that the
condition is not being met?

Thanks in advance,

CM



  #13   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] clive.ming@hotmail.co.uk is offline
external usenet poster
 
Posts: 5
Default Mail merge .. . If Then Else

On 9 Feb, 07:25, "macropod" wrote:
Hi Doug,

Since there's no spaces in the test condition or true/false results, the field works equally well with no quote characters:
{IF{MERGEFIELD PatientCode \*Upper} = XX @}

Another potential issue is whether the 'PatientCode' field contains exactly 'XX' - no more & no less. The OP said "As part of the
testing i have printed to screen Value X to confirm it contains the data for the condition to be met". That's only one 'X'. Or is
'Value X' the name of a/the field?

Cheers

--
macropod
[MVP - Microsoft Word]

"Doug Robbins - Word MVP" wrote in l...
| Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"
|
| --
| 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
|| wrote in message

roups.com...
| On 8 Feb, 16:55, wrote:
| On 8 Feb, 16:15, "Graham Mayor" wrote:
|
|
|
|
|
| And do test the result of {Mergefield PatientCode} without a condition
| to
| ensure it reproduces exactly what you think it should reproduce. Try
| also
|
| { IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
| --
|
| Graham Mayor - Word MVP
|
| My web sitewww.gmayor.com
| Word MVP web sitehttp://word.mvps.org
|
|
| Peter Jamieson wrote:
| 1. Are all the {} the special field code braces that you can insert
| using ctrl-F9?
| 2. Is the value definitely XX and not xx, xX etc?
| 3. Try adding double quotes around the { MERGEFIELD } field, i.e.
|
| { IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }
|
| Peter Jamieson
| wrote in message
| roups.com...
| On 8 Feb, 15:33, wrote:
| Hi - i am having a few problems with the if then else conditional
| statement with word mail merge. The logic that i am looking to
| implement is if Value X = XX then print @ else print nothing. The
| code is below. Now this seems very simple but for some reason
| doesnt work and even when the condition is met it does not print @.
| As part of the testing i have printed to screen Value X to confirm
| it contains the data for the condition to be met but it doesnt
| write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }
|
| So the issue i have is that although the condition seems to have
| been
| met it does not execute the correct part of the conditional
| statement. The data being used for the mail merge comes from a SQL
| 2000 SP3a database.- Hide quoted text -
|
| - Show quoted text -
|
| Hi - thanks for your suggestions - i cant try them at the moment as
| production is down . With regards word mail merge i dont have any
| exeperience apart from the hour or so that i have spent looking at
| this issue (although i have numerous years of development experience -
| somewhat offset by the fact i am now a manager ).
|
| In one of the suggestions the code used \*Upper - i pressume that
| there must be numerous other switches e.g. \*Lower etc. Is there a FAQ
| that describes all these 'switches' - cant seem to find mention of
| them Word Help.
|
| Thanks in advance,
|
| CM- Hide quoted text -
|
| - Show quoted text -
|
|
| Hi - just tried the suggested fix and it still doesnt work - the code
| is below;
|
| { IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }
|
| Any other suggestions - this is really frustrating because for all
| intents and purposes it should work. I have tried using the same
| logic with another merge field and it works fine - could there be
| anything in particular with this field that might mean that the
| condition is not being met?
|
| Thanks in advance,
|
| CM
|
|
|
|
|
|


Hi - thanks for all your responses but i still have the same issue.
The value in the merge field is XX - as part of the testing i did i
printed the merge field to screen and also concantenated a value
either side to confirm that only the XX was contained within - i used
the following;

"Start" MERGEFIELD PatientCode "End"

The output was;

StartXXEnd

So i know that there are no trailing white spaces.

This issue is really quite annoying - using the code provided in the
responses above it should in theory execute the IF statement for the
XX condition.

Any further suggestions greatly appreciated. Failing that i will try
and look for another merge field to use to generate the condition and
meet the business requirements needed in the front end.

Thanks in advance,

CM

  #14   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Mail merge .. . If Then Else

Hi CM,

OK, so how did you create the braces (ie '{ }') used in your field coding -
{ IF { MERGEFIELD PatientCode } = "XX" "@" "" }
The syntax you've posted is correct. But, if any of the braces were typed, the field won't work. You need to create them (in pairs)
via Ctrl-F9.

Cheers

| Hi - thanks for all your responses but i still have the same issue.
| The value in the merge field is XX - as part of the testing i did i
| printed the merge field to screen and also concantenated a value
| either side to confirm that only the XX was contained within - i used
| the following;
|
| "Start" MERGEFIELD PatientCode "End"
|
| The output was;
|
| StartXXEnd
|
| So i know that there are no trailing white spaces.
|
| This issue is really quite annoying - using the code provided in the
| responses above it should in theory execute the IF statement for the
| XX condition.
|
| Any further suggestions greatly appreciated. Failing that i will try
| and look for another merge field to use to generate the condition and
| meet the business requirements needed in the front end.
|
| Thanks in advance,
|
| CM
|


  #15   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail merge .. . If Then Else

As I've said before, there are occasions when you have to have at least some
of the quotes. They may be unusual, but it's good defensive programming to
use them, although of course, in the absence of a complete specification of
what fields do, even adding quotes isn't necessarily going to have the
desired result in all situations. For example, in this case, try inserting a
bookmark called XX in the document (it can be a regular bookmark or created
using { SET XX something }, then evaluate

{ IF {MERGEFIELD PatientCode \*Upper } = XX @ }

{ IF "{MERGEFIELD PatientCode \*Upper }" = XX @ }

{ IF {MERGEFIELD PatientCode \*Upper } = "XX" @ }

{ IF "{MERGEFIELD PatientCode \*Upper }" = "XX" @ }

I think only the last one works correctly where PatientCode is xx or XX.

That's why I usually advise use of quotes.

Peter Jamieson
"macropod" wrote in message
...
Hi Doug,

Since there's no spaces in the test condition or true/false results, the
field works equally well with no quote characters:
{IF{MERGEFIELD PatientCode \*Upper} = XX @}

Another potential issue is whether the 'PatientCode' field contains
exactly 'XX' - no more & no less. The OP said "As part of the
testing i have printed to screen Value X to confirm it contains the data
for the condition to be met". That's only one 'X'. Or is
'Value X' the name of a/the field?

Cheers

--
macropod
[MVP - Microsoft Word]


"Doug Robbins - Word MVP" wrote in message
...
| Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"
|
| --
| 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
|
| wrote in message
| oups.com...
| On 8 Feb, 16:55, wrote:
| On 8 Feb, 16:15, "Graham Mayor" wrote:
|
|
|
|
|
| And do test the result of {Mergefield PatientCode} without a
condition
| to
| ensure it reproduces exactly what you think it should reproduce.
Try
| also
|
| { IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
| --
|
| Graham Mayor - Word MVP
|
| My web sitewww.gmayor.com
| Word MVP web sitehttp://word.mvps.org
|
|
| Peter Jamieson wrote:
| 1. Are all the {} the special field code braces that you can
insert
| using ctrl-F9?
| 2. Is the value definitely XX and not xx, xX etc?
| 3. Try adding double quotes around the { MERGEFIELD } field, i.e.
|
| { IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }
|
| Peter Jamieson
| wrote in message
| roups.com...
| On 8 Feb, 15:33, wrote:
| Hi - i am having a few problems with the if then else
conditional
| statement with word mail merge. The logic that i am looking to
| implement is if Value X = XX then print @ else print nothing.
The
| code is below. Now this seems very simple but for some reason
| doesnt work and even when the condition is met it does not
print @.
| As part of the testing i have printed to screen Value X to
confirm
| it contains the data for the condition to be met but it doesnt
| write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }
|
| So the issue i have is that although the condition seems to have
| been
| met it does not execute the correct part of the conditional
| statement. The data being used for the mail merge comes from a
SQL
| 2000 SP3a database.- Hide quoted text -
|
| - Show quoted text -
|
| Hi - thanks for your suggestions - i cant try them at the moment as
| production is down . With regards word mail merge i dont have any
| exeperience apart from the hour or so that i have spent looking at
| this issue (although i have numerous years of development
experience -
| somewhat offset by the fact i am now a manager ).
|
| In one of the suggestions the code used \*Upper - i pressume that
| there must be numerous other switches e.g. \*Lower etc. Is there a
FAQ
| that describes all these 'switches' - cant seem to find mention of
| them Word Help.
|
| Thanks in advance,
|
| CM- Hide quoted text -
|
| - Show quoted text -
|
|
| Hi - just tried the suggested fix and it still doesnt work - the code
| is below;
|
| { IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }
|
| Any other suggestions - this is really frustrating because for all
| intents and purposes it should work. I have tried using the same
| logic with another merge field and it works fine - could there be
| anything in particular with this field that might mean that the
| condition is not being met?
|
| Thanks in advance,
|
| CM
|
|
|
|
|
|






  #16   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail merge .. . If Then Else

Did you try quoting all the comparands in your IF? Do you have a bookmark
called XX in your document (e.g. a { SET XX } field? Or perhaps even a field
called XX in your data source? (I haven't checked that particular
possibility.

Peter Jamieson

wrote in message
ps.com...
On 9 Feb, 07:25, "macropod" wrote:
Hi Doug,

Since there's no spaces in the test condition or true/false results, the
field works equally well with no quote characters:
{IF{MERGEFIELD PatientCode \*Upper} = XX @}

Another potential issue is whether the 'PatientCode' field contains
exactly 'XX' - no more & no less. The OP said "As part of the
testing i have printed to screen Value X to confirm it contains the data
for the condition to be met". That's only one 'X'. Or is
'Value X' the name of a/the field?

Cheers

--
macropod
[MVP - Microsoft Word]

"Doug Robbins - Word MVP" wrote in
l...
| Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"
|
| --
| 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
|| wrote in message

roups.com...
| On 8 Feb, 16:55, wrote:
| On 8 Feb, 16:15, "Graham Mayor" wrote:
|
|
|
|
|
| And do test the result of {Mergefield PatientCode} without a
condition
| to
| ensure it reproduces exactly what you think it should reproduce.
Try
| also
|
| { IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
| --
|
| Graham Mayor - Word MVP
|
| My web sitewww.gmayor.com
| Word MVP web sitehttp://word.mvps.org
|
|
| Peter Jamieson wrote:
| 1. Are all the {} the special field code braces that you can
insert
| using ctrl-F9?
| 2. Is the value definitely XX and not xx, xX etc?
| 3. Try adding double quotes around the { MERGEFIELD } field,
i.e.
|
| { IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }
|
| Peter Jamieson
| wrote in message
| roups.com...
| On 8 Feb, 15:33, wrote:
| Hi - i am having a few problems with the if then else
conditional
| statement with word mail merge. The logic that i am looking
to
| implement is if Value X = XX then print @ else print nothing.
The
| code is below. Now this seems very simple but for some reason
| doesnt work and even when the condition is met it does not
print @.
| As part of the testing i have printed to screen Value X to
confirm
| it contains the data for the condition to be met but it doesnt
| write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }
|
| So the issue i have is that although the condition seems to
have
| been
| met it does not execute the correct part of the conditional
| statement. The data being used for the mail merge comes from a
SQL
| 2000 SP3a database.- Hide quoted text -
|
| - Show quoted text -
|
| Hi - thanks for your suggestions - i cant try them at the moment as
| production is down . With regards word mail merge i dont have any
| exeperience apart from the hour or so that i have spent looking at
| this issue (although i have numerous years of development
experience -
| somewhat offset by the fact i am now a manager ).
|
| In one of the suggestions the code used \*Upper - i pressume that
| there must be numerous other switches e.g. \*Lower etc. Is there a
FAQ
| that describes all these 'switches' - cant seem to find mention of
| them Word Help.
|
| Thanks in advance,
|
| CM- Hide quoted text -
|
| - Show quoted text -
|
|
| Hi - just tried the suggested fix and it still doesnt work - the code
| is below;
|
| { IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }
|
| Any other suggestions - this is really frustrating because for all
| intents and purposes it should work. I have tried using the same
| logic with another merge field and it works fine - could there be
| anything in particular with this field that might mean that the
| condition is not being met?
|
| Thanks in advance,
|
| CM
|
|
|
|
|
|


Hi - thanks for all your responses but i still have the same issue.
The value in the merge field is XX - as part of the testing i did i
printed the merge field to screen and also concantenated a value
either side to confirm that only the XX was contained within - i used
the following;

"Start" MERGEFIELD PatientCode "End"

The output was;

StartXXEnd

So i know that there are no trailing white spaces.

This issue is really quite annoying - using the code provided in the
responses above it should in theory execute the IF statement for the
XX condition.

Any further suggestions greatly appreciated. Failing that i will try
and look for another merge field to use to generate the condition and
meet the business requirements needed in the front end.

Thanks in advance,

CM



  #17   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Mail merge .. . If Then Else

Is XX the actual result or something that represents the actual result? If
the latter, what is the *actual* result of that field?

--

Graham Mayor - Word MVP

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


wrote:
On 9 Feb, 07:25, "macropod" wrote:
Hi Doug,

Since there's no spaces in the test condition or true/false results,
the field works equally well with no quote characters:
{IF{MERGEFIELD PatientCode \*Upper} = XX @}

Another potential issue is whether the 'PatientCode' field contains
exactly 'XX' - no more & no less. The OP said "As part of the
testing i have printed to screen Value X to confirm it contains the
data for the condition to be met". That's only one 'X'. Or is 'Value
X' the name of a/the field?

Cheers

--
macropod
[MVP - Microsoft Word]

"Doug Robbins - Word MVP" wrote in
l...
Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"

--
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
wrote in message
oups.com... On 8
Feb, 16:55, wrote:
On 8 Feb, 16:15, "Graham Mayor" wrote:





And do test the result of {Mergefield PatientCode} without a
condition to
ensure it reproduces exactly what you think it should reproduce.
Try also

{ IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
--

Graham Mayor - Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org


Peter Jamieson wrote:
1. Are all the {} the special field code braces that you can
insert using ctrl-F9?
2. Is the value definitely XX and not xx, xX etc?
3. Try adding double quotes around the { MERGEFIELD } field,
i.e.

{ IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }

Peter Jamieson
wrote in message
oups.com...
On 8 Feb, 15:33, wrote:
Hi - i am having a few problems with the if then else
conditional statement with word mail merge. The logic that i
am looking to implement is if Value X = XX then print @ else
print nothing. The code is below. Now this seems very
simple but for some reason doesnt work and even when the
condition is met it does not print @. As part of the testing
i have printed to screen Value X to confirm it contains the
data for the condition to be met but it doesnt write the @. {
IF { MERGEFIELD PatientCode } = "XX" "@" "" }

So the issue i have is that although the condition seems to
have been
met it does not execute the correct part of the conditional
statement. The data being used for the mail merge comes from
a SQL 2000 SP3a database.- Hide quoted text -

- Show quoted text -

Hi - thanks for your suggestions - i cant try them at the moment
as production is down . With regards word mail merge i dont
have any exeperience apart from the hour or so that i have spent
looking at this issue (although i have numerous years of
development experience - somewhat offset by the fact i am now a
manager ).

In one of the suggestions the code used \*Upper - i pressume that
there must be numerous other switches e.g. \*Lower etc. Is there
a FAQ that describes all these 'switches' - cant seem to find
mention of them Word Help.

Thanks in advance,

CM- Hide quoted text -

- Show quoted text -


Hi - just tried the suggested fix and it still doesnt work - the
code is below;

{ IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }

Any other suggestions - this is really frustrating because for all
intents and purposes it should work. I have tried using the same
logic with another merge field and it works fine - could there be
anything in particular with this field that might mean that the
condition is not being met?

Thanks in advance,

CM







Hi - thanks for all your responses but i still have the same issue.
The value in the merge field is XX - as part of the testing i did i
printed the merge field to screen and also concantenated a value
either side to confirm that only the XX was contained within - i used
the following;

"Start" MERGEFIELD PatientCode "End"

The output was;

StartXXEnd

So i know that there are no trailing white spaces.

This issue is really quite annoying - using the code provided in the
responses above it should in theory execute the IF statement for the
XX condition.

Any further suggestions greatly appreciated. Failing that i will try
and look for another merge field to use to generate the condition and
meet the business requirements needed in the front end.

Thanks in advance,

CM



  #18   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Mail merge .. . If Then Else

Hi Peter,

Actually, after removing the 'MERGEFIELD', for use with an ASK field, all those scenarios work for 'XX' as a string, but not as a
bookmark. Tested with:
{QUOTE{ASK PatientCode}"1"
{IF {PatientCode \*Upper} = XX @}"2"
{IF "{PatientCode \*Upper}" = XX @}"3"
{ IF {PatientCode \*Upper} = "XX" @}"4"
{IF "{PatientCode \*Upper}" = "XX" @}}

If you input 'XX' or 'xx' into the 'ASK PatientCode' field, you get '1@2@3@4@' as the output. Anything else returns nothing, which
is as it should be. Mergefields work the same way.

If XX is a bookmark, as in:
{QUOTE{ASK PatientCode}{ASK XX}"1"
{IF {PatientCode \*Upper} = XX @}"2"
{IF "{PatientCode \*Upper}" = XX @}"3"
{ IF {PatientCode \*Upper} = "XX" @}"4"
{IF "{PatientCode \*Upper}" = "XX" @}}
and input 'XX' or 'xx' into the 'ASK PatientCode' field, you get '1@2@34' as the output (ie only the first and second versions
work). Anything else returns nothing.

If you want to use 'XX' as a bookmark, that will work in the 3rd & 4th cases too *if the 'XX' is in a field*, as in:
{QUOTE{ASK PatientCode}{ASK XX}"1"
{IF {PatientCode \*Upper} = {XX} @}"2"
{IF "{PatientCode \*Upper}" = {XX} @}"3"
{ IF {PatientCode \*Upper} = "{XX}" @}"4"
{IF "{PatientCode \*Upper}" = "{XX}" @}}
Now, if you input 'AA' or 'aa' into the 'ASK PatientCode' field, and 'AA' (upper case only) in the 'ASK XX' field, or any other
matching characters, you get '1@2@3@4@' as the output but anything else returns nothing.

Cheers

--
macropod
[MVP - Microsoft Word]


"Peter Jamieson" wrote in message ...
| As I've said before, there are occasions when you have to have at least some
| of the quotes. They may be unusual, but it's good defensive programming to
| use them, although of course, in the absence of a complete specification of
| what fields do, even adding quotes isn't necessarily going to have the
| desired result in all situations. For example, in this case, try inserting a
| bookmark called XX in the document (it can be a regular bookmark or created
| using { SET XX something }, then evaluate
|
| { IF {MERGEFIELD PatientCode \*Upper } = XX @ }
|
| { IF "{MERGEFIELD PatientCode \*Upper }" = XX @ }
|
| { IF {MERGEFIELD PatientCode \*Upper } = "XX" @ }
|
| { IF "{MERGEFIELD PatientCode \*Upper }" = "XX" @ }
|
| I think only the last one works correctly where PatientCode is xx or XX.
|
| That's why I usually advise use of quotes.
|
| Peter Jamieson
| "macropod" wrote in message
| ...
| Hi Doug,
|
| Since there's no spaces in the test condition or true/false results, the
| field works equally well with no quote characters:
| {IF{MERGEFIELD PatientCode \*Upper} = XX @}
|
| Another potential issue is whether the 'PatientCode' field contains
| exactly 'XX' - no more & no less. The OP said "As part of the
| testing i have printed to screen Value X to confirm it contains the data
| for the condition to be met". That's only one 'X'. Or is
| 'Value X' the name of a/the field?
|
| Cheers
|
| --
| macropod
| [MVP - Microsoft Word]
|
|
| "Doug Robbins - Word MVP" wrote in message
| ...
| | Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"
| |
| | --
| | 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
| |
| | wrote in message
| | oups.com...
| | On 8 Feb, 16:55, wrote:
| | On 8 Feb, 16:15, "Graham Mayor" wrote:
| |
| |
| |
| |
| |
| | And do test the result of {Mergefield PatientCode} without a
| condition
| | to
| | ensure it reproduces exactly what you think it should reproduce.
| Try
| | also
| |
| | { IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
| | --
| |
| | Graham Mayor - Word MVP
| |
| | My web sitewww.gmayor.com
| | Word MVP web sitehttp://word.mvps.org
| |
| |
| | Peter Jamieson wrote:
| | 1. Are all the {} the special field code braces that you can
| insert
| | using ctrl-F9?
| | 2. Is the value definitely XX and not xx, xX etc?
| | 3. Try adding double quotes around the { MERGEFIELD } field, i.e.
| |
| | { IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }
| |
| | Peter Jamieson
| | wrote in message
| | roups.com...
| | On 8 Feb, 15:33, wrote:
| | Hi - i am having a few problems with the if then else
| conditional
| | statement with word mail merge. The logic that i am looking to
| | implement is if Value X = XX then print @ else print nothing.
| The
| | code is below. Now this seems very simple but for some reason
| | doesnt work and even when the condition is met it does not
| print @.
| | As part of the testing i have printed to screen Value X to
| confirm
| | it contains the data for the condition to be met but it doesnt
| | write the @. { IF { MERGEFIELD PatientCode } = "XX" "@" "" }
| |
| | So the issue i have is that although the condition seems to have
| | been
| | met it does not execute the correct part of the conditional
| | statement. The data being used for the mail merge comes from a
| SQL
| | 2000 SP3a database.- Hide quoted text -
| |
| | - Show quoted text -
| |
| | Hi - thanks for your suggestions - i cant try them at the moment as
| | production is down . With regards word mail merge i dont have any
| | exeperience apart from the hour or so that i have spent looking at
| | this issue (although i have numerous years of development
| experience -
| | somewhat offset by the fact i am now a manager ).
| |
| | In one of the suggestions the code used \*Upper - i pressume that
| | there must be numerous other switches e.g. \*Lower etc. Is there a
| FAQ
| | that describes all these 'switches' - cant seem to find mention of
| | them Word Help.
| |
| | Thanks in advance,
| |
| | CM- Hide quoted text -
| |
| | - Show quoted text -
| |
| |
| | Hi - just tried the suggested fix and it still doesnt work - the code
| | is below;
| |
| | { IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }
| |
| | Any other suggestions - this is really frustrating because for all
| | intents and purposes it should work. I have tried using the same
| | logic with another merge field and it works fine - could there be
| | anything in particular with this field that might mean that the
| | condition is not being met?
| |
| | Thanks in advance,
| |
| | CM
| |
| |
| |
| |
| |
| |
|
|
|
|


  #19   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail merge .. . If Then Else

Sorry, had to dash earlier and my examples were not quite as I had tested
before posting. And certainly with the \*Upper, the "quoteless" example
works as you say.

But I don't actually get the same results as you describe below either. For
example.

1.
{QUOTE{ASK PatientCode}"1"
{IF {PatientCode \*Upper} = XX @}"2"
{IF "{PatientCode \*Upper}" = XX @}"3"
{ IF {PatientCode \*Upper} = "XX" @}"4"
{IF "{PatientCode \*Upper}" = "XX" @}}

If you input 'XX' or 'xx' into the 'ASK PatientCode' field, you get
'1@2@3@4@' as the output. Anything else
returns nothing, which
is as it should be. Mergefields work the same way.


Yes, that's what I get assuming "nothing" means "1234" :-) I haven't
re-checked the Mergefields scenario yet.

2.
If XX is a bookmark, as in:
{QUOTE{ASK PatientCode}{ASK XX}"1"
{IF {PatientCode \*Upper} = XX @}"2"
{IF "{PatientCode \*Upper}" = XX @}"3"
{ IF {PatientCode \*Upper} = "XX" @}"4"
{IF "{PatientCode \*Upper}" = "XX" @}}
and input 'XX' or 'xx' into the 'ASK PatientCode' field, you get '1@2@34'
as the output (ie only the first and second versions
work). Anything else returns nothing.


Here, I don't get 1@2@34 in any circumstances. I wonder why our results are
different?

If PatientCode is xx or XX, and I input nothing into XX, I get 1@2@3@4@,
possibly because Word removes the XX bookmark in that case and it's
effectively the same test as (1). Howerver, I also get the same result if
PatientCode is xx or XX and I input "XX" (without the quotes) into XX.

If PatientCode is xx or XX, and I input anything except blank or XX into the
XX field, I get 1@234@ , i.e. versions 1 and 4 work OK.

If PatientCode is aa, I always get 1234.

3.
If you want to use 'XX' as a bookmark, that will work in the 3rd & 4th
cases too *if the 'XX' is in a field*, as in:
{QUOTE{ASK PatientCode}{ASK XX}"1"
{IF {PatientCode \*Upper} = {XX} @}"2"
{IF "{PatientCode \*Upper}" = {XX} @}"3"
{ IF {PatientCode \*Upper} = "{XX}" @}"4"
{IF "{PatientCode \*Upper}" = "{XX}" @}}
Now, if you input 'AA' or 'aa' into the 'ASK PatientCode' field, and 'AA'
(upper case only) in the 'ASK XX' field, or any other
matching characters, you get '1@2@3@4@' as the output but anything else
returns nothing.


I get the same

4. Now if you go back to (2) and remove the \*Upper (which was the scenario
I was actually testing this morning):

If XX is a bookmark, as in:
{QUOTE{ASK PatientCode}{ASK XX}"1"
{IF {PatientCode } = XX @}"2"
{IF "{PatientCode }" = XX @}"3"
{ IF {PatientCode } = "XX" @}"4"
{IF "{PatientCode }" = "XX" @}}


a. PatientCode=xx,XX=xx: 1@2@34
b. PatientCode=xx,XX=XX: 1@23@4
c. PatientCode=XX,XX=xx: 1@234@
d. PatientCode=XX,XX=XX: 1@2@3@4@
e. PatientCode=aa,XX=aa: 1@2@34
f. PatientCode=aa,XX=AA: 1234
g. PatientCode=AA,XX=aa: 1234
h. PatientCode=AA,XX=AA: 1@2@34
i. PatientCode=aa,XX=xx: 1234
j. PatientCode=aa,XX=XX: 1234
k. PatientCode=AA,XX=xx: 1234
l. PatientCode=AA,XX=XX: 1234
m. PatientCode=xx,XX=aa: 1@234
n. PatientCode=xx,XX=AA: 1@234
o. PatientCode=XX,XX=aa: 1@234@
p. PatientCode=XX,XX=AA: 1@234@
q. PatientCode=aa,XX=PatientCode

Only the fully quoted version correctly compares PatientCode with "XX" every
time. As I understand it, what's happening is that Word looks at the
unquoted { PatientCode } and if it's xx or XX, uses the value of { xx }/{
XX } which are the same, and uses { XX } when it sees unquoted XX. At least
I think that explanation fits everything. In which case there is always
potentially a problem if an unquoted field's contents happens to match the
name of a bookmark. Adding the \*Upper switch seems to make things work
differently, and perhaps other things do as well, but I haven't worked right
through the samples on that front.

Which is all very well, but may still not result in a solution for the
original question...

Regards,

Peter Jamieson


"macropod" wrote in message
...
Hi Peter,

Actually, after removing the 'MERGEFIELD', for use with an ASK field, all
those scenarios work for 'XX' as a string, but not as a
bookmark. Tested with:
{QUOTE{ASK PatientCode}"1"
{IF {PatientCode \*Upper} = XX @}"2"
{IF "{PatientCode \*Upper}" = XX @}"3"
{ IF {PatientCode \*Upper} = "XX" @}"4"
{IF "{PatientCode \*Upper}" = "XX" @}}

If you input 'XX' or 'xx' into the 'ASK PatientCode' field, you get
'1@2@3@4@' as the output. Anything else returns nothing, which
is as it should be. Mergefields work the same way.

If XX is a bookmark, as in:
{QUOTE{ASK PatientCode}{ASK XX}"1"
{IF {PatientCode \*Upper} = XX @}"2"
{IF "{PatientCode \*Upper}" = XX @}"3"
{ IF {PatientCode \*Upper} = "XX" @}"4"
{IF "{PatientCode \*Upper}" = "XX" @}}
and input 'XX' or 'xx' into the 'ASK PatientCode' field, you get '1@2@34'
as the output (ie only the first and second versions
work). Anything else returns nothing.

If you want to use 'XX' as a bookmark, that will work in the 3rd & 4th
cases too *if the 'XX' is in a field*, as in:
{QUOTE{ASK PatientCode}{ASK XX}"1"
{IF {PatientCode \*Upper} = {XX} @}"2"
{IF "{PatientCode \*Upper}" = {XX} @}"3"
{ IF {PatientCode \*Upper} = "{XX}" @}"4"
{IF "{PatientCode \*Upper}" = "{XX}" @}}
Now, if you input 'AA' or 'aa' into the 'ASK PatientCode' field, and 'AA'
(upper case only) in the 'ASK XX' field, or any other
matching characters, you get '1@2@3@4@' as the output but anything else
returns nothing.

Cheers

--
macropod
[MVP - Microsoft Word]


"Peter Jamieson" wrote in message
...
| As I've said before, there are occasions when you have to have at least
some
| of the quotes. They may be unusual, but it's good defensive programming
to
| use them, although of course, in the absence of a complete specification
of
| what fields do, even adding quotes isn't necessarily going to have the
| desired result in all situations. For example, in this case, try
inserting a
| bookmark called XX in the document (it can be a regular bookmark or
created
| using { SET XX something }, then evaluate
|
| { IF {MERGEFIELD PatientCode \*Upper } = XX @ }
|
| { IF "{MERGEFIELD PatientCode \*Upper }" = XX @ }
|
| { IF {MERGEFIELD PatientCode \*Upper } = "XX" @ }
|
| { IF "{MERGEFIELD PatientCode \*Upper }" = "XX" @ }
|
| I think only the last one works correctly where PatientCode is xx or XX.
|
| That's why I usually advise use of quotes.
|
| Peter Jamieson
| "macropod" wrote in message
| ...
| Hi Doug,
|
| Since there's no spaces in the test condition or true/false results,
the
| field works equally well with no quote characters:
| {IF{MERGEFIELD PatientCode \*Upper} = XX @}
|
| Another potential issue is whether the 'PatientCode' field contains
| exactly 'XX' - no more & no less. The OP said "As part of the
| testing i have printed to screen Value X to confirm it contains the
data
| for the condition to be met". That's only one 'X'. Or is
| 'Value X' the name of a/the field?
|
| Cheers
|
| --
| macropod
| [MVP - Microsoft Word]
|
|
| "Doug Robbins - Word MVP" wrote in message
| ...
| | Remove the quotation marks from "{ MERGEFIELD PatientCode \*Upper}"
| |
| | --
| | 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
| |
| | wrote in message
| | oups.com...
| | On 8 Feb, 16:55, wrote:
| | On 8 Feb, 16:15, "Graham Mayor"
wrote:
| |
| |
| |
| |
| |
| | And do test the result of {Mergefield PatientCode} without a
| condition
| | to
| | ensure it reproduces exactly what you think it should
reproduce.
| Try
| | also
| |
| | { IF { MERGEFIELD PatientCode \*Upper} = "XX" "@" }
| | --
| |
| | Graham Mayor - Word MVP
| |
| | My web sitewww.gmayor.com
| | Word MVP web sitehttp://word.mvps.org
| |
| |
| | Peter Jamieson wrote:
| | 1. Are all the {} the special field code braces that you can
| insert
| | using ctrl-F9?
| | 2. Is the value definitely XX and not xx, xX etc?
| | 3. Try adding double quotes around the { MERGEFIELD } field,
i.e.
| |
| | { IF "{ MERGEFIELD PatientCode }" = "XX" "@" "" }
| |
| | Peter Jamieson
| | wrote in message
| | roups.com...
| | On 8 Feb, 15:33, wrote:
| | Hi - i am having a few problems with the if then else
| conditional
| | statement with word mail merge. The logic that i am
looking to
| | implement is if Value X = XX then print @ else print
nothing.
| The
| | code is below. Now this seems very simple but for some
reason
| | doesnt work and even when the condition is met it does not
| print @.
| | As part of the testing i have printed to screen Value X to
| confirm
| | it contains the data for the condition to be met but it
doesnt
| | write the @. { IF { MERGEFIELD PatientCode } = "XX" "@"
"" }
| |
| | So the issue i have is that although the condition seems to
have
| | been
| | met it does not execute the correct part of the conditional
| | statement. The data being used for the mail merge comes
from a
| SQL
| | 2000 SP3a database.- Hide quoted text -
| |
| | - Show quoted text -
| |
| | Hi - thanks for your suggestions - i cant try them at the moment
as
| | production is down . With regards word mail merge i dont have
any
| | exeperience apart from the hour or so that i have spent looking
at
| | this issue (although i have numerous years of development
| experience -
| | somewhat offset by the fact i am now a manager ).
| |
| | In one of the suggestions the code used \*Upper - i pressume that
| | there must be numerous other switches e.g. \*Lower etc. Is there
a
| FAQ
| | that describes all these 'switches' - cant seem to find mention
of
| | them Word Help.
| |
| | Thanks in advance,
| |
| | CM- Hide quoted text -
| |
| | - Show quoted text -
| |
| |
| | Hi - just tried the suggested fix and it still doesnt work - the
code
| | is below;
| |
| | { IF "{ MERGEFIELD PatientCode \*Upper}" = "XX" "@" }
| |
| | Any other suggestions - this is really frustrating because for all
| | intents and purposes it should work. I have tried using the same
| | logic with another merge field and it works fine - could there be
| | anything in particular with this field that might mean that the
| | condition is not being met?
| |
| | Thanks in advance,
| |
| | CM
| |
| |
| |
| |
| |
| |
|
|
|
|




  #20   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Mail merge .. . If Then Else

Hi Peter,

| Sorry, had to dash earlier and my examples were not quite as I had tested before posting.
| And certainly with the \*Upper, the "quoteless" example works as you say.
|
| But I don't actually get the same results as you describe below either. For example.
|
| 1.
| Yes, that's what I get assuming "nothing" means "1234" :-)

Um, yes - "nothing" means "1234" - Ooops

| 2.
| Here, I don't get 1@2@34 in any circumstances. I wonder why our results are different?

Nor do I now. Curious. Repeated it a number of times before my last post ...

| If PatientCode is xx or XX, and I input nothing into XX, I get 1@2@3@4@,

Even curiouser, but true.This can be rectified by coding the field along the lines of:
{IF "{PatientCode \*Upper}" = {XX} T F} or {IF "{PatientCode \*Upper}" = "{XX}" T F}
but not:
{IF "{PatientCode \*Upper}" = {REF XX} T F} or {IF "{PatientCode \*Upper}" = "{REF XX}" T F}


| However, I also get the same result if
| PatientCode is xx or XX and I input "XX" (without the quotes) into XX.

Which is as expected.

| If PatientCode is xx or XX, and I input anything except blank or XX into the
| XX field, I get 1@234@ , i.e. versions 1 and 4 work OK.

No, the result of the test is False; that means only versions 2 & 3 work in this case.

| If PatientCode is aa, I always get 1234.

Same here, which is what I'd expect.

| 3.
| I get the same

I'm glad.

|
| 4.

OK, so here's a comparison of using the 'XX' bookmark as a plain vanilla 'XX', '{XX}' and '{REF XX}', using the field coded as:
{QUOTE{ASK PatientCode}{ASK XX}
"1"{IF {PatientCode} = XX T F}
"2"{IF "{PatientCode}" = XX T F}
"3"{ IF {PatientCode} = "XX" T F}
"4"{IF "{PatientCode}" = "XX" T F}}
The minor re-coding, to output T/F and reposition the numbers against the corresponding IF tests, has no effect on the correctness
of the results. I also added a few more tests and omitted your incomplete 'q'.

State 'XX' '{XX}' '{REF XX}'
a. PatientCode=xx,XX=xx: TRUE 1T2T3F4F 1T2T3T4T 1T2T3T4T
b. PatientCode=xx,XX=XX: FALSE 1T2F3T4F 1T2F3T4F 1T2F3T4F
c. PatientCode=XX,XX=xx: FALSE 1T2F3F4T 1T2F3T4F 1T2F3T4F
d. PatientCode=XX,XX=XX: TRUE 1T2T3T4T 1T2T3T4T 1T2T3T4T
e. PatientCode=aa,XX=aa: TRUE 1T2T3F4F 1T2T3T4T 1T2T3T4T
f. PatientCode=aa,XX=AA: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
g. PatientCode=AA,XX=aa: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
h. PatientCode=AA,XX=AA: TRUE 1T2T3F4F 1T2T3T4T 1T2T3T4T
i. PatientCode=aa,XX=xx: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
j. PatientCode=aa,XX=XX: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
k. PatientCode=AA,XX=xx: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
l. PatientCode=AA,XX=XX: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
m. PatientCode=xx,XX=aa: FALSE 1T2F3F4F 1T2F3T4F 1T2F3T4F
n. PatientCode=xx,XX=AA: FALSE 1T2F3F4F 1T2F3T4F 1T2F3T4F
o. PatientCode=XX,XX=aa: FALSE 1T2F3F4T 1T2F3T4F 1T2F3T4F
p. PatientCode=XX,XX=AA: FALSE 1T2F3F4T 1T2F3T4F 1T2F3T4F
q.
r. PatientCode="",XX="": TRUE 1F2F3F4F 1T2T3T4T 1F2F3F4F
s. PatientCode=xx,XX="": FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
t. PatientCode="",XX=xx: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F

For the plain vanilla 'XX', I get the same results as you did.

| Only the fully quoted version correctly compares PatientCode with "XX" every
| time.

My interpretation differs: What the tests show is that only version 2 returned the correct result every time with plain vanilla
'XX'- until we got to test 'r'. Versions 2 and 4 of the REF field coded as '{REF XX}' gave the same results.

My tests also show that only versions 2 and 4 of the REF field coded as '{XX}' returned the correct result every time, including
test 'r'. I have no idea why omitting 'REF' from the field code should make a difference to that test, but it does.

My take on this is that it's easier to remember, and therefore safer in practice, to use quoted REF fields (without the REF) on both
sides of the equation when testing bookmarked strings. As previously discussed, the testing of bookmarked strings against other
strings needs quotes around any test string that has spaces in it, but not around the bookmark. However, since the field works with
or without quotes around the bookmark, and having them makes for consistency with testing bookmarks against each other, I'd have to
endorse putting quotes around everything as the safest way to code an IF field. I guess I should now go and review/update my
'tutorial' documents.

|
| Which is all very well, but may still not result in a solution for the
| original question...

Sadly, all too true. But it's been an interesting exercise in its own right.

Cheers

--
macropod
[MVP - Microsoft Word]




  #21   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mail merge .. . If Then Else

Hi macropod,

Sadly, all too true. But it's been an interesting exercise in its own
right.


It certainly has!

My interpretation differs: What the tests show is that only version 2
returned the correct result every time with plain vanilla
'XX'- until we got to test 'r'. Versions 2 and 4 of the REF field coded as
'{REF XX}' gave the same results.


I /think/ this is because we have a different understanding of what is being
tested. If your interpretation is that the presence of an XX bookmark means
that "XX" should be interepreted as the result of { XX } then option 4
definitely does not work for case 'XX'. But to me, using "XX" should, and as
far as I can tell, always does, mean that you are testing against the string
"XX" rather than the result of the bookmark XX - in which case, option 4
works every time AFAICS. Is it important? Well, I suppose the reality is
that if you have complete control over every aspect of a merge, you can
avoid problems of this kind as long as you know they exist, and if you don't
have complete control then there are any number of things that could get
screwed up because someone changes something. But I suppose it's worth
trying to guard against the possibility that the user might insert an XX
bookmark in "my" Mail Merge Main document or attach the document to a Word
data source with a column called XX - in which case Word treats the column
names like bookmarks - mostly.

That's another place where you will find a difference between the treatment
of { mybm } and { REF mybm }. If you attach a Word data source with a column
called mybm, Word inserts value of the column mybm when you use those
fields. But the two versions behave diffeerently when you toggle the
preview button: For { mybm }, it always displays the field value. For { REF
mybm } it displays "Error! Reference source not found." in the state where
MERGE fields are shown enclosed in chevrons, but the column value when the
field results are displayed. At least it does, here, right now :-) Using
those column names as if they were bookmarks may be an undocumented feature
(you can use it to insert pictures, for example) whose consequences should
be regarded as unpredictable but of course that does not prevent users from
attaching, quite legitimately, to Word document data sources.

In the end all this stuff probably comes down to the Word code being
developed over time, based on more than one interpretation of how exactly
fields are supposed to behave. For example, if you bookmark a { SEQ } field
as myseq in Word 2003 and use { REF myseq } to reference it, you see the
result of that { SEQ } field. However, way back in Word 2, either { REF
myseq } or { myseq }, or both - I forget which - actually behaved as if it
were another copy of the SEQ field itself and give you the next number in
the sequence. This was very nice for implementing SEQ-based numbering
because you could set a bookmark called (say) l2 to { SEQ level2 \c }.{ SEQ
level1 } and use { l2 } to produce each new number at that level. That
disappeared in Word 6 or maybe later, but perhaps some of the code relating
to REF fields is still in there. My assumption is that even specifying the
field language is non-trivial because of the kind of problem you encounter
when evaluating nested fields - for example, is it obvious how SEQ fields
nested inside IF fields should be evaluated? I don't know.

It was interesting that you seemed to have some different results when you
revisited the problem, because that's pretty much what happened to me
yesterday! In my case I'm pretty sure it was experimental error, but I do
sometimes wonder whehter there isn't some subtle error in Word (perhaps to
do with what you've done during a session, or what bookmarks exist in other
open documents, or some such).

Regards,

Peter Jamieson


Cheers

--
macropod


"macropod" wrote in message
...
Hi Peter,

| Sorry, had to dash earlier and my examples were not quite as I had
tested before posting.
| And certainly with the \*Upper, the "quoteless" example works as you
say.
|
| But I don't actually get the same results as you describe below either.
For example.
|
| 1.
| Yes, that's what I get assuming "nothing" means "1234" :-)

Um, yes - "nothing" means "1234" - Ooops

| 2.
| Here, I don't get 1@2@34 in any circumstances. I wonder why our results
are different?

Nor do I now. Curious. Repeated it a number of times before my last post
...

| If PatientCode is xx or XX, and I input nothing into XX, I get 1@2@3@4@,

Even curiouser, but true.This can be rectified by coding the field along
the lines of:
{IF "{PatientCode \*Upper}" = {XX} T F} or {IF "{PatientCode \*Upper}" =
"{XX}" T F}
but not:
{IF "{PatientCode \*Upper}" = {REF XX} T F} or {IF "{PatientCode \*Upper}"
= "{REF XX}" T F}


| However, I also get the same result if
| PatientCode is xx or XX and I input "XX" (without the quotes) into XX.

Which is as expected.

| If PatientCode is xx or XX, and I input anything except blank or XX into
the
| XX field, I get 1@234@ , i.e. versions 1 and 4 work OK.

No, the result of the test is False; that means only versions 2 & 3 work
in this case.

| If PatientCode is aa, I always get 1234.

Same here, which is what I'd expect.

| 3.
| I get the same

I'm glad.

|
| 4.

OK, so here's a comparison of using the 'XX' bookmark as a plain vanilla
'XX', '{XX}' and '{REF XX}', using the field coded as:
{QUOTE{ASK PatientCode}{ASK XX}
"1"{IF {PatientCode} = XX T F}
"2"{IF "{PatientCode}" = XX T F}
"3"{ IF {PatientCode} = "XX" T F}
"4"{IF "{PatientCode}" = "XX" T F}}
The minor re-coding, to output T/F and reposition the numbers against the
corresponding IF tests, has no effect on the correctness
of the results. I also added a few more tests and omitted your incomplete
'q'.

State 'XX' '{XX}' '{REF XX}'
a. PatientCode=xx,XX=xx: TRUE 1T2T3F4F 1T2T3T4T 1T2T3T4T
b. PatientCode=xx,XX=XX: FALSE 1T2F3T4F 1T2F3T4F 1T2F3T4F
c. PatientCode=XX,XX=xx: FALSE 1T2F3F4T 1T2F3T4F 1T2F3T4F
d. PatientCode=XX,XX=XX: TRUE 1T2T3T4T 1T2T3T4T 1T2T3T4T
e. PatientCode=aa,XX=aa: TRUE 1T2T3F4F 1T2T3T4T 1T2T3T4T
f. PatientCode=aa,XX=AA: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
g. PatientCode=AA,XX=aa: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
h. PatientCode=AA,XX=AA: TRUE 1T2T3F4F 1T2T3T4T 1T2T3T4T
i. PatientCode=aa,XX=xx: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
j. PatientCode=aa,XX=XX: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
k. PatientCode=AA,XX=xx: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
l. PatientCode=AA,XX=XX: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
m. PatientCode=xx,XX=aa: FALSE 1T2F3F4F 1T2F3T4F 1T2F3T4F
n. PatientCode=xx,XX=AA: FALSE 1T2F3F4F 1T2F3T4F 1T2F3T4F
o. PatientCode=XX,XX=aa: FALSE 1T2F3F4T 1T2F3T4F 1T2F3T4F
p. PatientCode=XX,XX=AA: FALSE 1T2F3F4T 1T2F3T4F 1T2F3T4F
q.
r. PatientCode="",XX="": TRUE 1F2F3F4F 1T2T3T4T 1F2F3F4F
s. PatientCode=xx,XX="": FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F
t. PatientCode="",XX=xx: FALSE 1F2F3F4F 1F2F3F4F 1F2F3F4F

For the plain vanilla 'XX', I get the same results as you did.

| Only the fully quoted version correctly compares PatientCode with "XX"
every
| time.

My interpretation differs: What the tests show is that only version 2
returned the correct result every time with plain vanilla
'XX'- until we got to test 'r'. Versions 2 and 4 of the REF field coded as
'{REF XX}' gave the same results.

My tests also show that only versions 2 and 4 of the REF field coded as
'{XX}' returned the correct result every time, including
test 'r'. I have no idea why omitting 'REF' from the field code should
make a difference to that test, but it does.

My take on this is that it's easier to remember, and therefore safer in
practice, to use quoted REF fields (without the REF) on both
sides of the equation when testing bookmarked strings. As previously
discussed, the testing of bookmarked strings against other
strings needs quotes around any test string that has spaces in it, but not
around the bookmark. However, since the field works with
or without quotes around the bookmark, and having them makes for
consistency with testing bookmarks against each other, I'd have to
endorse putting quotes around everything as the safest way to code an IF
field. I guess I should now go and review/update my
'tutorial' documents.

|
| Which is all very well, but may still not result in a solution for the
| original question...

Sadly, all too true. But it's been an interesting exercise in its own
right.

Cheers

--
macropod
[MVP - Microsoft Word]




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
Word crashes when I try to mail merge using Outlook recipients Medicalst Mailmerge 3 January 3rd 07 10:39 AM
Mail Merge insert merge fields Dannyl Mailmerge 1 December 12th 06 05:51 AM
Mail Merge Dannyl Mailmerge 0 December 12th 06 03:40 AM
Heavy Mail Merge Application Atul Mailmerge 1 August 17th 06 02:37 PM
How to get all mail merge fields in a document [email protected] Mailmerge 3 February 17th 06 05:43 AM


All times are GMT +1. The time now is 08:08 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"