Solved

I Need Help with Syntax on this Access Query

Posted on 2015-02-10
7
84 Views
Last Modified: 2015-02-10
My Query is shown below... Access keeps autobracketing the "Text" items in the NOT Statements when i save the query, and then prompts me to ENTER A PARAMETER VALUE for each as the query executes. Can someone please help me get this functional?

SELECT Format([Created On],"yyyy-mm") AS MonthandYear, Sum(KO_QN_Data.[DefectQty (ext)]) AS Total_QNs INTO Barry_Monthly_KO_QN_Total
FROM KO_QN_Data
WHERE KO_QN_Data.[Short text for code]="Kimball Office Furniture"
AND ( GetBucket([Code group] ) ="Product" OR GetBucket([Code group]) ="Delivery")
AND clng([Created On]) < clng(dateserial(Year(date() ),Month(date()),1))
AND NOT [Code Group] = “ZVOID”
AND NOT [Code Group] = “PRODSUGG”
AND NOT [Code Group] = “C&CERROR”
AND NOT [Code Group] = “RAWMATL”
AND NOT [Code Group] IS NULL
GROUP BY Format([Created On],"yyyy-mm")
ORDER BY Format([Created On],"yyyy-mm");
0
Comment
Question by:Rex85
  • 4
  • 3
7 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 40600656
“  is not the same as "  maybe you just put the "wrong" double quotes?
0
 

Author Comment

by:Rex85
ID: 40600665
No... I just tried changing them. Access changes them back when i save it and does the same thing
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40600680
Please try this:

AND [Code Group] NOT IN ( "ZVOID", "PRODSUGG", "C&CERROR", "RAWMATL")

the same way, you may want to change (for performance) this:
AND ( GetBucket([Code group] ) ="Product" OR GetBucket([Code group]) ="Delivery")
into this
AND ( GetBucket([Code group] )  IN ( "Product" , "Delivery") )
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:Rex85
ID: 40600693
OK. Great... That worked. Thank you.

Is there a way i can incorporate the Null avoidance in that? ...or is it OK as is?

I currently have...

AND NOT [Code Group] IS NULL
0
 
LVL 142

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 500 total points
ID: 40600698
you cannot incorporate that into the IN or NOT IN, however:
AND NOT [Code Group] IS NULL

should be
AND [Code Group] IS NOT NULL
0
 

Author Comment

by:Rex85
ID: 40600703
Fantastic! Thank you very much.

Rex
0
 

Author Closing Comment

by:Rex85
ID: 40600709
Great. Very Quick and concise. Thank you.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sum Multiple Columns in Access Query 5 49
Auto Filter in Combo Box 7 32
Close Print Preview button not active 12 36
Access Query based on a Form Field 2 18
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now