Groups | Search | Server Info | Login | Register
Groups > comp.databases.ms-access > #839
| From | "David-W-Fenton" <NoEmail@SeeSignature.invalid> |
|---|---|
| Newsgroups | comp.databases.ms-access |
| Subject | Re: dynamic criteria being ignored by query |
| Date | 2011-04-06 17:16 +0000 |
| Organization | David Fenton Associates |
| Message-ID | <Xns9EBF871C0F996f99a49ed1d0c49c5bbb2@74.209.136.92> (permalink) |
| References | <5c35353f-1827-4170-bc4e-57826cf3522c@d28g2000yqf.googlegroups.com> |
Tony_E <bluestealth94@hotmail.com> wrote in
news:5c35353f-1827-4170-bc4e-57826cf3522c@d28g2000yqf.googlegroups.co
m:
> I am trying to implement dynamic criteria into a query instead of
> hard- coding a range. It is a date/time field. I want the query to
> retrieve a range of data based on what day of the week it is. I
> tried the following in the criteria of this date/time field:
>
> IIf(Format(Now(),"DDDD")in ("Monday","Tuesday","Wednesday")
> >=Date()-5,IIf(Format(Now(),"DDDD")in ("Thursday","Friday")
> >=Date()-3))
>
> The query ignores it and retrieves all the data.
Are there any OR's in the WHERE clause? If so, you might need to use
parentheses to get the right result. For instance:
WHERE condition1 OR condition2 AND condition 3
...will be unpredictable as to what it will retrieve. It could
alternatively be interpreted in either of these two ways:
WHERE (condition1 OR condition2) AND condition 3
WHERE condition1 OR (condition2 AND condition 3)
The parentheses are essential to insure that it gets interpreted in
the way you want it to be interpreted.
--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
Back to comp.databases.ms-access | Previous | Next — Previous in thread | Next in thread | Find similar
dynamic criteria being ignored by query Tony_E <bluestealth94@hotmail.com> - 2011-04-05 05:16 -0700
Re: dynamic criteria being ignored by query "zuckermanf@gmail.com" <zuckermanf@gmail.com> - 2011-04-05 07:52 -0700
Re: dynamic criteria being ignored by query Tony_E <bluestealth94@hotmail.com> - 2011-04-05 07:57 -0700
Re: dynamic criteria being ignored by query John Spencer <JSPENCER@Hilltop.umbc> - 2011-04-05 11:36 -0400
Re: dynamic criteria being ignored by query Tony_E <bluestealth94@hotmail.com> - 2011-04-05 08:46 -0700
Re: dynamic criteria being ignored by query "David-W-Fenton" <NoEmail@SeeSignature.invalid> - 2011-04-06 17:16 +0000
Re: dynamic criteria being ignored by query "Douglas J Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> - 2011-04-07 17:29 -0400
Re: dynamic criteria being ignored by query "David-W-Fenton" <NoEmail@SeeSignature.invalid> - 2011-04-09 21:22 +0000
Re: dynamic criteria being ignored by query "Douglas J Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> - 2011-04-10 09:12 -0400
csiph-web