hello
i have a set of numbers 1-52 in a field. when i query criteria ...between
[weekvar] and [weekvar]-13....i get the answer i need with the query: a set
of numbers.
However, when i put this same condition within an iif statement in the query
criteria, it doesn't work and comes up with no results.
iif([weekvar]>13, between [weekvar] and [weekvar]-13, 100).
The "100" answer will work, but the "between" will not query anything.
What i am trying to do is to return a set of numbers while using iif(.
I don't understand why it'll work when alone in the criteria, but not when
inside an iif(.
Forgive me for my ignorance, I am an amateur.
|
|
0
|
|
|
|
Reply
|
Utf
|
11/20/2009 12:26:01 AM |
|
Justin T <Justin T@discussions.microsoft.com> wrote:
>i have a set of numbers 1-52 in a field. when i query criteria ...between
>[weekvar] and [weekvar]-13....i get the answer i need with the query: a set
>of numbers.
>
>However, when i put this same condition within an iif statement in the query
>criteria, it doesn't work and comes up with no results.
>
>iif([weekvar]>13, between [weekvar] and [weekvar]-13, 100).
>
>The "100" answer will work, but the "between" will not query anything.
>
>What i am trying to do is to return a set of numbers while using iif(.
>
>I don't understand why it'll work when alone in the criteria, but not when
>inside an iif(.
It won't work because you have part of the syntax for the
expression inside the IIf and Access can not parse the
expression. You need to keep the complete expression in one
place. And don't forget that a criteria must evaluate to
True or False
iif([weekvar]>13, thefield between [weekvar] and
[weekvar]-13, True)
--
Marsh
MVP [MS Access]
|
|
0
|
|
|
|
Reply
|
Marshall
|
11/20/2009 3:35:42 AM
|
|
The following is the equivalent of what you posted. I'm not sure it is what
you want, since if you enter any number greater than 13 you will get NO
records returned if the values in the field range from 1 to 52.
Between IIF([WeekVar]>13,[Weekvar]-13,100) and IIF([WeekVar]>13,[WeekVar],100)
Perhaps what you want is
Somefield >=IIF([WeekVar]>52,[Weekvar]-13,0)
and SomeField <=IIF([WeekVar]>52,[WeekVar],100)
which will limit records to a 13 number range or return all records that have
a value in the field.
If you want all records even if the value is null then you might enter
criteria like the following
((Between [WeekVar]-13 and [Weekvar]) or [WeekVar]>52)
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
Justin T wrote:
> hello
>
> i have a set of numbers 1-52 in a field. when i query criteria ...between
> [weekvar] and [weekvar]-13....i get the answer i need with the query: a set
> of numbers.
>
> However, when i put this same condition within an iif statement in the query
> criteria, it doesn't work and comes up with no results.
>
> iif([weekvar]>13, between [weekvar] and [weekvar]-13, 100).
>
> The "100" answer will work, but the "between" will not query anything.
>
> What i am trying to do is to return a set of numbers while using iif(.
>
> I don't understand why it'll work when alone in the criteria, but not when
> inside an iif(.
>
> Forgive me for my ignorance, I am an amateur.
|
|
0
|
|
|
|
Reply
|
John
|
11/20/2009 2:15:17 PM
|
|
|
2 Replies
634 Views
(page loaded in 0.043 seconds)
Similiar Articles: IIF Between (two numbers not cells) expression - microsoft.public ...I want to write a statement that goes something like if [smrhcc] is not null then " ", if [smrhcc] is between 110 and 160, then pass, else fail. Belo... IIf function, & Date(), & AND, & > & < ...I'm trying to get the query to check if an anniversary date is within the next 30 days, so I tried using this formula, but it did not work. Your he... iif and date range - microsoft.public.access.queriesI have following criteria for my query. I wanted different date range if it is Friday or not. IIf(Weekday(Date())=6,Between Day(Date()) And Day(Date... Iif Statement help - microsoft.public.accessHi, basically i need a soltuion which is a huge Iif statement ibelieve maybe a nested Iif staement.OK basically i want the statement to be like this:I... DLookup within Iif statement - microsoft.public.access.queries ...I'm having trouble getting an Iif Statement that includes a Dlookup to work. Here is what I have but the records where the Iif is true show nothing ... IIF and Like? - microsoft.public.access.queriesI need to create a indicator field that will look at a field and see if it has a certain code in it and then return a Y or N. I was thinking that I could use an IIF ... IIf function to calculate field - microsoft.public.access.queries ...Hello, I'm running into an issue and was hoping someone could help. I have a query that I'd like to calculate the time between two dates. There are ... Access query with IIF statements is null for a field and not null ...I am trying to insert a comma between [name] and [section name] field if the [name] field is not null - but I don't want the comma if the [name] fie... IIf return multiple categories - microsoft.public.access ...On Thu, 01 Apr 2010 12:31:13 -0400, John Spencer <spencer@chpdm.edu> wrote: >Also, you may have to potential for missing some values depending on how the >BMI is ... Return a date range based on today's date - microsoft.public ...I need to build a query (to be used for eternity) to return records for dates between ... Year( DateAdd("m", -6, now( ) )), 7, 1) + Iotas.Iota FROM Iotas WHERE iota<= iif ... IIF Between (two numbers not cells) expression DataBaseI want to write a statement that goes something like if [smrhcc] is not null then , if [smrhcc] is between 110 and 160, then pass, else fail. Below is w iif and between DataBase - DataBase Discussion List Tuesday, May ...hello i have a set of numbers 1-52 in a field. when i query criteria ...between [weekvar] and [weekvar]-13....i get the answer i need with the query: a s Run a query that uses "IIF" & "Between" in Access | SQL Server ...Access 2002 and SQL 2000 Server. How to run a query that uses "IIF" and "Between" in an Access project file (ADP) ? I have an Access project file (ADP),... Between...And Operator - Access - Office.comThe following example determines whether an order was shipped to a location within a range of postal codes. If the postal code is between 98101 and 98199, the IIf function ... MS Access: iif Function - TechOnTheNet.comIn Access, the iif function returns one value if a specified condition evaluates to TRUE, or another value if it evaluates to FALSE. 7/26/2012 10:44:55 PM
|