OR syntax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Criteria for a number field in query design view is coming from a Form
unbound text box.

[Forms]![Form1].[NumberTxtBox]

When user puts X (i.e. 100) in that textbox and runs the query - all the
records with a 100 value are returned...works fine.

But in this design for the user to put in >X into the textbox (i.e. >100)
it will not work - returns 0 records; the > symbol is literally not in the
field.

(Note: if one puts >100 directly into the query design criteria - it
works....it does not work via the [Forms]![Form1].[NumberTxtBox] method)

Also when the text box is left empty - it is desired that this is
interpreted as "All"...

How would these two needs be accomplished? thnx
 
You cannot include an operator (such as greater than) as a parameter value.

Typically, people try to use the Like operator with wildcard to handle all,
but that approach is doomed as well: it does not returns nulls.

The best solution is to build the query statement (or filter) from the boxes
where the user enters a value. You can use a combo for the operator, and
build the statement in code.

There's an example of building the filter statement in code in this article:
Search form - Handle many optional criteria
at:
http://allenbrowne.com/ser-62.html
 
Back
Top