Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
AJ AJ is offline
external usenet poster
 
Posts: 36
Default string comparison

I have a mailmerge document with a datasource of an Access Table. I am
needing help. I am wondering what the syntax of a "Like" comparison statement
would be in Word. I have a text field with multiple selections in it, and I
need a different statement for each one. So, what I want is Word to look at
this field and if it has a 1 in this text field put in this statement and so
on. But there can be more than one statement for each letter. I have done
like statements in Access but can't seem to find a syntax for it in Word.
Basically what I am wanting is somewhat listed below:
{If {MergeField Reason} Like *1*, "put this in"}
{If {MergeField Reason} Like *M*, "put this in"}
and so on. Any help would be greatly appreciated..

Thanks,
AJ
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default string comparison

The nearest the "Word field language" gets to "like" is that you can do

{ If {MergeField Reason} = "M*" "put this in" }

and

{ If {MergeField Reason} = "*M" "put this in" }

but unfortunately you cannot have wildcards at the beginning /and/ end
of the comparand, so you cannot do

{ If {MergeField Reason} = "*M*" "put this in" }

Approaches to work around this depend on the precise requirement but a
fairly general-purpose approach would be to create an Access query that
did the comparisons, returning additional columns, and use that as the
data source. e.g. something like

SELECT myfielda,iif(reason like '*M*',1,0) AS [containsM],myfieldb
FROM ...whatever...

then in word

{ If {MergeField containsM} = 1 "put this in" }


Peter Jamieson

http://tips.pjmsn.me.uk

AJ wrote:
I have a mailmerge document with a datasource of an Access Table. I am
needing help. I am wondering what the syntax of a "Like" comparison statement
would be in Word. I have a text field with multiple selections in it, and I
need a different statement for each one. So, what I want is Word to look at
this field and if it has a 1 in this text field put in this statement and so
on. But there can be more than one statement for each letter. I have done
like statements in Access but can't seem to find a syntax for it in Word.
Basically what I am wanting is somewhat listed below:
{If {MergeField Reason} Like *1*, "put this in"}
{If {MergeField Reason} Like *M*, "put this in"}
and so on. Any help would be greatly appreciated..

Thanks,
AJ

  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
AJ AJ is offline
external usenet poster
 
Posts: 36
Default string comparison

I was afraid of that. I will just go the route you suggested to do it in
Access then come into Word. I just didn't know if I was missing something.
Thank you for you time and knowledge.
Thanks

"Peter Jamieson" wrote:

The nearest the "Word field language" gets to "like" is that you can do

{ If {MergeField Reason} = "M*" "put this in" }

and

{ If {MergeField Reason} = "*M" "put this in" }

but unfortunately you cannot have wildcards at the beginning /and/ end
of the comparand, so you cannot do

{ If {MergeField Reason} = "*M*" "put this in" }

Approaches to work around this depend on the precise requirement but a
fairly general-purpose approach would be to create an Access query that
did the comparisons, returning additional columns, and use that as the
data source. e.g. something like

SELECT myfielda,iif(reason like '*M*',1,0) AS [containsM],myfieldb
FROM ...whatever...

then in word

{ If {MergeField containsM} = 1 "put this in" }


Peter Jamieson

http://tips.pjmsn.me.uk

AJ wrote:
I have a mailmerge document with a datasource of an Access Table. I am
needing help. I am wondering what the syntax of a "Like" comparison statement
would be in Word. I have a text field with multiple selections in it, and I
need a different statement for each one. So, what I want is Word to look at
this field and if it has a 1 in this text field put in this statement and so
on. But there can be more than one statement for each letter. I have done
like statements in Access but can't seem to find a syntax for it in Word.
Basically what I am wanting is somewhat listed below:
{If {MergeField Reason} Like *1*, "put this in"}
{If {MergeField Reason} Like *M*, "put this in"}
and so on. Any help would be greatly appreciated..

Thanks,
AJ


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
Comparison Function Maurice Microsoft Word Help 1 October 2nd 08 04:17 PM
If fields for comparison [email protected] Microsoft Word Help 2 April 3rd 07 11:30 PM
Comparison Table PaulG Microsoft Word Help 0 March 28th 07 12:19 AM
Document Comparison Diane F Microsoft Word Help 1 March 11th 06 12:41 AM
document comparison software [email protected] Microsoft Word Help 0 June 10th 05 09:57 PM


All times are GMT +1. The time now is 02:30 PM.

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

About Us

"It's about Microsoft Word"