A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

IIF Limitation



 
 
Thread Tools Display Modes
  #1  
Old May 27th, 2004, 01:31 PM
JA
external usenet poster
 
Posts: n/a
Default 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  
Old May 27th, 2004, 01:58 PM
Michel Walsh
external usenet poster
 
Posts: n/a
Default 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  
Old May 28th, 2004, 07:08 AM
John Vinson
external usenet poster
 
Posts: n/a
Default 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  
Old May 28th, 2004, 11:46 AM
Dann
external usenet poster
 
Posts: n/a
Default IIF Limitation

You Could try

Training Week: "Week " & (Format([Start Date],"ww",2)-17)

regards

Dan
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.