473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Less Than / Greater Than in query criteria

I have searched high and low and cannot find an answer to my problem.
So now I turn to the collective genius of this newsgroup.

Over-simplified examples
This query criteria for field [recdate] works:
IIf(1=1,#3/12/2007#,#3/12/2007#)
1=1 will be replaced by actual 'test'; I just want to make sure
expression evaluates 'true'
Query returns all records where [recdate] field equals
3/12/2007date

This query criteria for field [recdate] DOES NOT work:
IIf(1=1,<=#3/12/2007#,>=#3/12/2007#)
1=1 will be replaced by actual 'test'; I just want to make sure
expression evaluates 'true'
I *expect* all records where the value for field [recdate] is
equal to or less than 3/12/2007

I get NO records!

I have tried thousands (well... at least hundreds) of syntax
variations and I cannot get this to work. *ANY* operator symbol (>, <
or =) kills the query. No error... just no records. I'm ready for a
beer.

Would one of you please point out what I am doing incorrectly. Your
help would be very much appreciated!

gary b

Sep 26 '07 #1
3 48967
sf***@earthlink.net wrote:
I have searched high and low and cannot find an answer to my problem.
So now I turn to the collective genius of this newsgroup.

Over-simplified examples
This query criteria for field [recdate] works:
IIf(1=1,#3/12/2007#,#3/12/2007#)
1=1 will be replaced by actual 'test'; I just want to make sure
expression evaluates 'true'
Query returns all records where [recdate] field equals
3/12/2007date

This query criteria for field [recdate] DOES NOT work:
IIf(1=1,<=#3/12/2007#,>=#3/12/2007#)
1=1 will be replaced by actual 'test'; I just want to make sure
expression evaluates 'true'
I *expect* all records where the value for field [recdate] is
equal to or less than 3/12/2007

I get NO records!

I have tried thousands (well... at least hundreds) of syntax
variations and I cannot get this to work. *ANY* operator symbol (>, <
or =) kills the query. No error... just no records. I'm ready for a
beer.

Would one of you please point out what I am doing incorrectly. Your
help would be very much appreciated!

gary b
You cannot conditionally change your comparison operator like that. You
need to use an OR criteria like...

SELECT...
WHERE (1=1 AND SomeField <= #3/12/2007#)
OR (1<>1 AND SomeField >= #3/12/2007#)
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Sep 26 '07 #2
On Sep 26, 9:51 am, "Rick Brandt" <rickbran...@hotmail.comwrote:
You cannot conditionally change your comparison operator like that. You
need to use an OR criteria like...

SELECT...
WHERE (1=1 AND SomeField <= #3/12/2007#)
OR (1<>1 AND SomeField >= #3/12/2007#)
Thanks, Rick! That approach never occurred to me. I will give it a
try and post results. Please note that I found no similar info in any
of my newsgroup searches on this topic. Maybe your information will
help someone else, too.

Thanks, again!

Sep 26 '07 #3
I tried your suggestion and it works fine, Rick. Thanks for sharing
your knowledge!!

gary b

Sep 26 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: keliie | last post by:
Hello Just a quick question that I've spent a few hours trying to solve with no luck (although one would think this should be fairly easy). I have a form with a subform. The subform is based...
3
by: stevecat | last post by:
Hi there, I have created a form, "search" and a query "search_product". The query returns the product information based upon the criteria for three of the fields, author, title or isbn. The field...
4
waynetheengineer
by: waynetheengineer | last post by:
Hi, I was wondering if anyone had any suggestions on my database: I have a form that accepts user input into a single text box. When the OK button is hit, a query should search for all records...
3
by: ericargent | last post by:
Hi I'm using Acces 2003 I have Query where the several parameters for the criteria are supplied from a form. One parameter source is a combo box. What I am trying to do is if: An item is...
6
craigfr
by: craigfr | last post by:
I am making a graph comparing last year's defect data with YTD defect data. Our fiscal year starts Nov.1 and ends Oct.31. To get the YTD, I started used a simple date serial criteria: Between...
2
by: cmartin1986 | last post by:
First of all I want to thank all of you that have helped me in the past this is an awesome fourm. My problem today is I have a database that builds charts that are viewed by a large group every...
4
by: tbeers | last post by:
Is there a method to pass along a criteria argument directly to the query criteria rather than through filtering a form or report? In other words, I would like to click a "print" button and in the...
8
by: limperger | last post by:
Hello everyone! First and foremost, my apologies for the title of the post. It is not very clarifying of what the problem is about, but I didn't know how to put it... My problem is as follows: I...
9
ajhayes
by: ajhayes | last post by:
Hello everyone, This is my first time posting here and I'm hoping someone can help me out. I'm a relative newbie to Access and am pretty much learning as I go along, so please bear with me. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.