Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 24th, 2004, 09:33 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default Criteria query with multiple fields

Hi !
Running Access2002 why my criteria qry wont show correct result with more than two fields as criteria? Has anyone had this problem? I have to transform a two criteria qry into a table and run the last
criteria on this table to have the correct result.
Any suggestion will be welcome.
Regards Penta.

 
Old October 24th, 2004, 10:17 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Penta-

It's hard to figure out what you might be doing wrong without knowing the SQL of the query you tried or the structure of your tables. Please post the SQL from your query that doesn't work. Open the query in Design view, choose SQL View from the View menu, and paste the text you see into a reply.


John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
 
Old October 24th, 2004, 03:21 PM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear John:
Now it is running.Probably afraid of your proficience.I posted the topic because
it has been happening several times with different tables.Anyway i have split
the qry in two qrys and i run a maketable qry on the first qry before i reach
the result: when the problem persists.The qry is:
SELECT tblSales.*
FROM tblSales
WHERE (((tblSales.fkCompanyID)=10) AND (([tblSales]![DateDispatched]-[tblSales]![DateOrdered])>7) AND ((tblSales.DateOrdered)>=#11/1/1998# And (tblSales.DateOrdered)<=#11/30/1998#));

Thank You very much for ur time and care.
Truly P.

 
Old October 24th, 2004, 04:36 PM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Penta-

Hmmm. I'm suspicious that AND is capitalized in one place but not another - as though the query is performaing a logical AND in the wrong place. I hate the extra parens that the query builder throws in. I would write the predicate like this:

(tblSales.fkCompanyID = 10) AND
(([tblSales]![DateDispatched]-[tblSales]![DateOrdered])>7) AND
(tblSales.DateOrdered >= #11/1/1998#) AND
(tblSales.DateOrdered <= #11/30/1998#)

Are you running on a U.S. machine? Access SQL requires date literals in strict mm/dd/yyyy sequence, and this can get confused on a machine that uses a different format for short date. Also, if your DateOrdered field can possibly contain a time component, you should change the last criteria to:

(tblSales.fkCompanyID = 10) AND
(([tblSales]![DateDispatched]-[tblSales]![DateOrdered])>7) AND
(tblSales.DateOrdered >= #11/1/1998#) And
(tblSales.DateOrdered < #12/1/1998#)



John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
 
Old October 25th, 2004, 06:25 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

John:
I have a dd/mm/yyyy as date literals.
I will follow ur advise although i dont know SQL. I have English Access
running in Brazilian language.
Thanks u very much again,
Truly P.

 
Old October 25th, 2004, 08:09 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Penta-

When you design a query using the query grid on a non-U.S. machine, you should see the dates displayed in dd/mm/yyyy format, but the SQL should be corrected to mm/dd/yyyy. So, you should see, for example, #1/11/1998# on the query grid but #11/1/1998# in SQL View. You should make a copy of your query, switch to SQL view, and try replacing the WHERE clause with what I suggested earlier. If you see a different layout when you switch back to Design view, then you had the criteria laid out incorrectly on your grid.



John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
 
Old October 25th, 2004, 09:01 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

John-
I will do it.
By the way ur book about SQL is out of print.
Thanks u very much again,
Truly P.



 
Old October 25th, 2004, 09:42 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Penta-

No, the "Mere Mortals" book just had its eighth or ninth printing. Amazon has it and ships in 24 hours:

http://www.amazon.com/exec/obidos/AS...escaconsulinc/



John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
 
Old October 25th, 2004, 11:54 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had just checked Amazon before sending the post and the site probably was not
updated. Now the status has changed. I will look for it as soon as possible.
Thanks John,
Truly P.










Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple criteria on a select query? jihadbuster XSLT 4 March 19th, 2008 01:52 PM
IIF multiple criteria stealthdevil Access VBA 10 November 28th, 2007 11:37 AM
Multiple Search Criteria in a Form tet Access VBA 5 October 27th, 2007 08:54 AM
stLinkCriteria - Multiple Criteria andyv123 Access 1 September 8th, 2006 10:02 AM
Multiple criteria for a Report stealthdevil Access VBA 33 June 8th, 2006 10:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.