Re: Is Like/Not Like options
- From: "Jeff Boyce" <JeffBoyce_IF@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Oct 2005 06:34:07 -0700
If by "decades" you mean a ten-year band starting with x0 and ending with
x9, you'd need to specific that the third character of the year was the
number you are seeking (e.g., looking for "9" to find the 90's).
You could use wildcard characters in a criterion of your query. Something
like:
Like "##" & [?decade] & "#"
to prompt for the decade number. Note that this requires that you "feed" it
the year -- if you have a date/time field, you could use Year([YourField])
to start with the year.
--
Regards
Jeff Boyce
<Office/Access MVP>
"Contro" <contro81@xxxxxxx> wrote in message
news:1129550433.747219.235920@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi guys!
>
> I've ran into a problem. I'm basically trying to find the number of
> rows which contain values of certain decades. They can be in the
> formats
>
> 70, 60, 90
>
> 1990, 1995, 2000
>
> or maybe even
>
> 70, 1990, 20, 1980
>
> Basically I want the user to be able to enter the decade. So they'd
> enter either "9" and that would pick up entries of either 1990 and 95.
> The problem is making it pick up both that kind of entry with no
> problems. It's perfectly fine for other decades bar 1990, but the
> code, no matter how hard I try, keeps picking up entries for 1980 (any
> year with 19 at the front) as well as 90 when I search for decades
> inputting "9".
>
> Here is a snip of my code:
>
> WHERE (((Applications.[Year(s) of Qualification] LIKE "* " & [choice] &
> "#*" OR Applications.[Year(s) of Qualification] LIKE "*," & [choice] &
> "#*")
> AND
> Applications.[Year(s) of Qualification] NOT LIKE "* #" & [choice] &
> "##*" OR Applications.[Year(s) of Qualification] NOT LIKE "*,#" &
> [choice] & "##*")
> OR
> Applications.[Year(s) of Qualification] LIKE "* #" & [choice] & "##*"
> OR Applications.[Year(s) of Qualification] LIKE "*,#" & [choice] &
> "##*");
>
> This seems overly complicated, and I'm sure there is an easier way, but
> I just don't know how. Some kind of OR condition function available in
> the LIKE part or something...if you could help, that would be great!
> The code above doesn't work as it logically isn't sound. But I don't
> know how else to try it!
>
> I hope it makes sense. It's kind of hard to explain, but basically
> when searching for decades in the 90's, it picks up 1980 or 1975 or
> 1955 (picking up the nine).
>
> Thank you so much in advance!
>
> Contro.
>
.
- Follow-Ups:
- Re: Is Like/Not Like options
- From: Contro
- Re: Is Like/Not Like options
- Prev by Date: Re: Is Like/Not Like options
- Next by Date: Re: Crosstab Query Null Values
- Previous by thread: Re: Is Like/Not Like options
- Next by thread: Re: Is Like/Not Like options
- Index(es):