Help with Where clause please

G

Guest

Can someone please tell me what's wrong with this query. At first before
saving the query I would get the proper results, ie., whatever was in the
txtbox on frmSearchAll would be retrieved, but after saving all records are
retrieved. Here is the SQL

SELECT qryAllFleet.*
FROM qryAllFleet

WHERE (((qryAllFleet.[Order number]=[forms]![frmSearchAll]![txtOrderNumber])
OR( [forms]![frmSearchAll]![txtOrderNumber] Is Null))

AND

((qryAllFleet.[Stknumber]=[forms]![frmSearchAll]![txtStockNumber]) OR
([forms]![frmSearchAll]![txtStockNumber] Is Null))

AND

((qryAllFleet.[ShortVin]=[forms]![frmSearchAll]![txtLast6]) OR(
[forms]![frmSearchAll]![txtLast6] Is Null)));


Any help would be greatly qppreciated.
 
G

Guest

Gary:

The query looks fine to me. You could prune out some of the redundant
parentheses ( you just need three sets, one around each of the Boolean OR
operations to force them to evaluate independently before the Boolean AND
operations) but it wouldn't affect how it works. The only thing I can think
of is that the txtLast6 control might not have been updated, i.e. a value has
been entered but the return or tab keys have not been hit. I've made this
mistake myself when testing queries which reference controls as parameters.

Ken Sheridan
Stafford, England
 
G

Guest

Oh how stupid can I be? Of course that is it, problem solved. As far as the
redundant parentheses is concerned, they are there simply because I threw
them in out out of frustration trying to make the query work. Thanks for
your help.
--
Gary in Michigan, USA


Ken Sheridan said:
Gary:

The query looks fine to me. You could prune out some of the redundant
parentheses ( you just need three sets, one around each of the Boolean OR
operations to force them to evaluate independently before the Boolean AND
operations) but it wouldn't affect how it works. The only thing I can think
of is that the txtLast6 control might not have been updated, i.e. a value has
been entered but the return or tab keys have not been hit. I've made this
mistake myself when testing queries which reference controls as parameters.

Ken Sheridan
Stafford, England

GaryS said:
Can someone please tell me what's wrong with this query. At first before
saving the query I would get the proper results, ie., whatever was in the
txtbox on frmSearchAll would be retrieved, but after saving all records are
retrieved. Here is the SQL

SELECT qryAllFleet.*
FROM qryAllFleet

WHERE (((qryAllFleet.[Order number]=[forms]![frmSearchAll]![txtOrderNumber])
OR( [forms]![frmSearchAll]![txtOrderNumber] Is Null))

AND

((qryAllFleet.[Stknumber]=[forms]![frmSearchAll]![txtStockNumber]) OR
([forms]![frmSearchAll]![txtStockNumber] Is Null))

AND

((qryAllFleet.[ShortVin]=[forms]![frmSearchAll]![txtLast6]) OR(
[forms]![frmSearchAll]![txtLast6] Is Null)));


Any help would be greatly qppreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top