Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help writing a function

Status
Not open for further replies.

WalkieTalkie

Technical User
Feb 15, 2002
91
NZ
I have an unbound textbox in a report that reads:

"has attended a " & [ProgrammeType]

I want to be able to get it to say "has attended an" when [ProgrammeType] begins with a vowel. I have unsuccessfully tried using the IIF function like so:

& IIf(Left([Value],1)="a" Or "e" Or "i" Or "o" Or "u","an ","a ")

...but it doesn't want to look at anything after the first "a". How do I get all those "Or"s into the expression?

Miranda
 
You need to check for each value, not just the first:

IIf(Left([Value],1)="a" Or Left([Value],1)="e" Or Left([Value],1)="i" Or Left([Value],1)="o" Or Left([Value],1)="u","an ","a ")

Larsson
 
I should have figured that out myself! Thanks for the help.

Miranda
 
Here is an easy way of searching a string for a char string.

IIf(Instr(1,"a,e,i,o,u",Left([Value],1))>0,"an ","a ")

This technique can be used for numbers also if you convert them to string and put a ,(comma) in front and behind all the individual number sets. You could use - or any special character as a seperator

IIf(Instr(1,",134,245,334,456,654,765,",CStr([IntegerValue]))>0,"Found String","Not Found")

Just passing on another way of doing it.


Bob Scriver
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top