If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
IIF Limitation
I am using IIF statement to specify weeks as shown below.
Unfortunately it does not allow me to go beyond 13 weeks. How can I overcome this limitation? TrainingWeek: IIf([StartDate] Between #01/May/04# And #07/May/04#,"Week 1",IIf([StartDate] Between #08/May/04# And #14/May/04#,"Week 2",IIf([StartDate] Between #15/May/04# And #21/May/04#,"Week 3",IIf([StartDate] Between #21/May/04# And #28/May/04#,"Week 4",IIf ([StartDate] Between #29/May/04# And #04/Jun/04#,"Week 5",IIf([StartDate] Between #05/Jun/04# And #11/Jun/04#,"Week 6",IIf([StartDate] Between #12/Jun/04# And #18/Jun/04#,"Week 7",IIf([StartDate] Between #19/Jun/04# And #25/Jun/04#,"Week 8",IIf([StartDate] Between #26/Jun/04# And #02/Jul/04#,"Week 9",IIf ([StartDate] Between #03/Jul/04# And #09/Jul/04#,"Week 10",IIf([StartDate] Between #10/Jul/04# And #16/Jul/04#,"Week 11",IIf([StartDate] Between #17/Jul/04# And #23/Jul/04#,"Week 12","")))))))))))) |
#2
|
|||
|
|||
IIF Limitation
Hi,
Use a table. Trainings ' table name Name, Starting, Ending ' fields name "week 1", #05-01-2004#, #05-07-2004# .... data then, in the query, bring that table and, under your actual StartDate (unknown table from your post), add the criteria: BETWEEN [Trainings].[Starting] AND [Training].[Ending] add the computed expression: TrainingWeek: [Trainings].[Name] Now, not only it is simpler, neat, and faster, it is also "re-usable" without having to touch any piece of SQL code! since the relevant data is in a table and end user knows how to change data in a table,... while letting them touch your SQL code is ... a risk. Hoping it may help, Vanderghast, Access MVP "JA" wrote in message ... I am using IIF statement to specify weeks as shown below. Unfortunately it does not allow me to go beyond 13 weeks. How can I overcome this limitation? TrainingWeek: IIf([StartDate] Between #01/May/04# And #07/May/04#,"Week 1",IIf([StartDate] Between #08/May/04# And #14/May/04#,"Week 2",IIf([StartDate] Between #15/May/04# And #21/May/04#,"Week 3",IIf([StartDate] Between #21/May/04# And #28/May/04#,"Week 4",IIf ([StartDate] Between #29/May/04# And #04/Jun/04#,"Week 5",IIf([StartDate] Between #05/Jun/04# And #11/Jun/04#,"Week 6",IIf([StartDate] Between #12/Jun/04# And #18/Jun/04#,"Week 7",IIf([StartDate] Between #19/Jun/04# And #25/Jun/04#,"Week 8",IIf([StartDate] Between #26/Jun/04# And #02/Jul/04#,"Week 9",IIf ([StartDate] Between #03/Jul/04# And #09/Jul/04#,"Week 10",IIf([StartDate] Between #10/Jul/04# And #16/Jul/04#,"Week 11",IIf([StartDate] Between #17/Jul/04# And #23/Jul/04#,"Week 12","")))))))))))) |
#3
|
|||
|
|||
IIF Limitation
On Thu, 27 May 2004 05:31:25 -0700, "JA"
wrote: I am using IIF statement to specify weeks as shown below. Unfortunately it does not allow me to go beyond 13 weeks. How can I overcome this limitation? As Michel says, a table-driven solution would be ideal; you might also want to consider the Switch() function - see the online help in the VBA editor - rather than nested IIF's. John W. Vinson[MVP] Come for live chats every Tuesday and Thursday http://go.compuserve.com/msdevapps?loc=us&access=public |
#4
|
|||
|
|||
IIF Limitation
You Could try
Training Week: "Week " & (Format([Start Date],"ww",2)-17) regards Dan |
Thread Tools | |
Display Modes | |
|
|