![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
On Fri, 24 Jun 2011 14:32:12 -0400, "Bob Barrows" reb01501 (AT) NOSPAMyahoo (DOT) com> wrote: Peter Jason wrote: For the "The" case I use: Expr1: Replace([MovieNameEnglish],"The ","") That will replace any occurence of "The" with an empty space, resulting in titles like "Phantom of Opera" and "Meet Fockers" And for the "A" case I use: Expr2: Replace([Expr1],"A ","") Same objection. Personally, I would create a VBA function to do this but it is possible with expressions: Expr1: iif(left([MovieNameEnglish],4)="The ",Mid([MovieNameEnglish],5) & ", The", [MovieNameEnglish]) Same idea for Expr2. Question: should you move "An " to the end of the title as well ("An Affair to Remember")? Thanks, but I can't get it to work: I type the above as: Expr4: iif(left([MovieNameEnglish],4)="The ",Mid([MovieNameEnglish],5) & ", The", [MovieNameEnglish]) The query grid acceps it, but nothing shows up when the query is run. Peter |
#12
| |||
| |||
|
|
Same objection. Personally, I would create a VBA function to do this but it is possible with expressions: Expr1: iif(left([MovieNameEnglish],4)="The ",Mid([MovieNameEnglish],5) & ", The", [MovieNameEnglish]) Unfortunately when I run the query and the report based on it, Access throws up a blank parameter box which requires two Cr for the query and report to run. You must have failed to remove the CRs when entering your expressions. This |
#13
| |||
| |||
|
|
IIf(Left([MovieNameEnglish],4)="The ",Mid([MovieNameEnglish],5) & ", The",[MovieNameEnglish]) |
#14
| |||
| |||
|
|
If you do it in the query, you need to nest the IIF statements all in one expression. *That expression might look like the following - all one line. IIf([MovieNameEnglish] Like "The *", Mid([MovieNameEnglish],5) & ", The" , IIF([MovieNameEnglish] Like "A *", Mid([MovieNameEnglish],3) & ", A") , IIF([MovieNameEnglish] Like "An *", Mid([MovieNameEnglish],4) & ", An" , [MovieNameEnglish]))) Note that the last choice was to return MovieNameEnglish in the case thatit did not start with The, An, or A. *Hope this helps. *As noted by Bob Barrows you **might** be better off using a custom VBA function to do this. John Spencer Access MVP 2002-2005, 2007-2010 The Hilltop Institute University of Maryland Baltimore County On 6/25/2011 1:39 AM, Peter Jason wrote: IIf(Left([MovieNameEnglish],4)="The ",Mid([MovieNameEnglish],5) & *", The",[MovieNameEnglish])- Hide quoted text - - Show quoted text - |
#15
| |||
| |||
|
|
A different approach..... I understand that you remove the words "A" and "The" in order to make sorting easier. Why not leave the title alone and create a query with one additional field called Title2. Title2 would be created by removing the selected words. Then, in your sorting and other functions, use the Title2 field. And when you want to use the true title, you still have the untouched field. Fred Zuckerman |
![]() |
| Thread Tools | |
| Display Modes | |
| |