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 statement too long. Other options?



 
 
Thread Tools Display Modes
  #1  
Old December 3rd, 2009, 02:15 PM posted to microsoft.public.access.queries
Christina[_2_]
external usenet poster
 
Posts: 2
Default IIf statement too long. Other options?

In my query I have a field with an iif statement that is too long now.

simple ex.
IIf([region]="LA",([date]-[daysLA])-[additionaldaysLA],
IIf([region]="NA",([date]-[daysNA])-[additionaldaysNA],([date]-[days])-
[additionaldays]))

Is there any way to convert this to a function to call from the query?


  #2  
Old December 3rd, 2009, 03:36 PM posted to microsoft.public.access.queries
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default IIf statement too long. Other options?

Christina -

Yes, you can create a public function to do this, or if you just need to
shorten it a little, you can use this instead:

=[date]-IIf([region]="LA",[daysLA]+[additionaldaysLA],
IIf([region]="NA",[daysNA]+[additionaldaysNA],[days]+[additionaldays]))

If you want it in a public function, then you will need to pass in all
values and return just the one date.

--
Daryl S


"Christina" wrote:

In my query I have a field with an iif statement that is too long now.

simple ex.
IIf([region]="LA",([date]-[daysLA])-[additionaldaysLA],
IIf([region]="NA",([date]-[daysNA])-[additionaldaysNA],([date]-[days])-
[additionaldays]))

Is there any way to convert this to a function to call from the query?


.

  #3  
Old December 3rd, 2009, 05:22 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default IIf statement too long. Other options?

On Thu, 3 Dec 2009 06:15:10 -0800 (PST), Christina wrote:

In my query I have a field with an iif statement that is too long now.

simple ex.
IIf([region]="LA",([date]-[daysLA])-[additionaldaysLA],
IIf([region]="NA",([date]-[daysNA])-[additionaldaysNA],([date]-[days])-
[additionaldays]))

Is there any way to convert this to a function to call from the query?


What's the context, Christina? Do you have a table with many Fields for
various days and additionaldays values as fields? If so, you're "committing
spreadsheet"; consider a tall-thin table with a field for Region, a field for
Days, and a field for Additionaldays. You could then simply use a join to this
table to look up the values, with no IIF statement at all.
--

John W. Vinson [MVP]
  #4  
Old December 3rd, 2009, 06:07 PM posted to microsoft.public.access.queries
Christina[_2_]
external usenet poster
 
Posts: 2
Default IIf statement too long. Other options?


Is there any way to convert this to a function to call from the query?


What's the context, Christina? Do you have a table with many Fields for
various *days and additionaldays values as fields? If so, you're "committing
spreadsheet"; consider a tall-thin table with a field for Region, a field for
Days, and a field for Additionaldays. You could then simply use a join to this
table to look up the values, with no IIF statement at all.
--

* * * * * * *John W. Vinson [MVP]




Thank you!!!
I think you're correct with committing spreadsheet. darn it!
I do need to go tall and skinny and look it up the table that way.


  #5  
Old December 3rd, 2009, 07:00 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default IIf statement too long. Other options?

On Thu, 3 Dec 2009 10:07:01 -0800 (PST), Christina wrote:


Is there any way to convert this to a function to call from the query?


What's the context, Christina? Do you have a table with many Fields for
various *days and additionaldays values as fields? If so, you're "committing
spreadsheet"; consider a tall-thin table with a field for Region, a field for
Days, and a field for Additionaldays. You could then simply use a join to this
table to look up the values, with no IIF statement at all.
--

* * * * * * *John W. Vinson [MVP]




Thank you!!!
I think you're correct with committing spreadsheet. darn it!
I do need to go tall and skinny and look it up the table that way.


Ego absolvo te, filia mea; go and sin no more!
--

John W. Vinson [MVP]
 




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 08:56 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.