Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / October 2004

Tip: Looking for answers? Try searching our database.

IF Statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AA2e72E - 07 Oct 2004 14:01 GMT
Depending on whether a variable length field (1 to 6 characters) contains the
letter L, I want to be able to insert different text. I tried:

{ IF CODE = "*L*"  "HAS L" "DOES NOT HAVE L" }

Why does this not work?
Graham Mayor - 07 Oct 2004 15:02 GMT
It doesn't work because the field does not accept wildcards.

> Depending on whether a variable length field (1 to 6 characters)
> contains the letter L, I want to be able to insert different text. I
[quoted text clipped - 3 lines]
>
> Why does this not work?

CODE is a field and and it appears that you can only have one wildcard
asterisk in the string. You can have an asterisk and more than one question
mark to represent single characters. Thus if Code was 'yellow' "??l*" would
work, "*w" would work , "y*" would work "y*w" would work, but "*l*" doesn't
work.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

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

AA2e72E - 07 Oct 2004 15:55 GMT
Thanks Graham.

I can get round with this:

{IF CODE = "L*" "HAS L" {IF CODE = "?L*" "HAS L" {IF CODE ="??L*" "HAS L" ….
More IF statements }}}

This gets very messy.

Is there any way I can use INSTR?

> It doesn't work because the field does not accept wildcards.
>
[quoted text clipped - 11 lines]
> work, "*w" would work , "y*" would work "y*w" would work, but "*l*" doesn't
> work.
macropod - 07 Oct 2004 21:46 GMT
Hi,

Testing whether a string contains a specified sub-string means testing for
the sub-string  at each position in the string. AFAIK there is no way around
testing for the sub-string  at specified positions. You could reduce the
number of nested IF tests by using (nested) OR tests, but I doubt that would
achieve much. Alternatively, you could sum a series of IF test results and
avoid nesting the IF tests altogether, as in:
{={IF CODE = "L*" 1 0}+{IF CODE = "?L*" 1 0}+{IF CODE = "??L*" 1 0}+{IF CODE
= "???L*" 1 0}+{IF CODE = "????L*" 1 0}+{IF CODE = "?????L*" 1 0}}

Cheers

> Thanks Graham.
>
> I can get round with this:
>
> {IF CODE = "L*" "HAS L" {IF CODE = "?L*" "HAS L" {IF CODE ="??L*" "HAS
L" ..
> More IF statements }}}
>
[quoted text clipped - 17 lines]
> > work, "*w" would work , "y*" would work "y*w" would work, but "*l*" doesn't
> > work.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.