Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
NZ and Crosstab Queries
Evans Pridgen 
    
5 years ago
Hi Richard, first thanks for your courses. I went from knowing nothing 5 years ago to being the go-to person in our company because I discovered your courses. I am stumped however on using NZ with a crosstab query to force a "0" instead of null. If it is in a course let me know which one to purchase.
Here is the query it excludes any part that has a quantity of "0"

TRANSFORM Nz(Sum(InventoryT.Qty))+0 AS SumOfQty
SELECT ComponentT.Part
FROM InventoryT LEFT JOIN ComponentT ON InventoryT.ComponentID = ComponentT.ComponentID
WHERE (((InventoryT.DOA)=True))
GROUP BY ComponentT.Part, ComponentT.ComponentID
ORDER BY ComponentT.ComponentID
PIVOT InventoryT.Qty;
Kevin Robertson  @Reply  
          
5 years ago
I think your problem is in the first line. Change to:

   TRANSFORM Nz(Sum(InventoryT.Qty),0) AS SumOfQty
Evans Pridgen OP  @Reply  
    
5 years ago
Thanks for the response. Unfortunately, this gives an invalid syntax error in the crosstab query.  The error is you may have entered an operand without an operator. I had tried this before but did it again just to confirm, but maybe I am doing something else wrong. Again thanks for your response and I am open to any suggestions. This is the first one I cannot figure out.
Richard Rost  @Reply  
           
5 years ago
How about this approach: show me a screen shot of what you HAVE (what your data looks like) and what you want the output to look like (mock it up in Excel or something). Then I can tell you how to get there in Access. Looking at your SQL doesn't help me because I can't envision the data.
Kevin Robertson  @Reply  
          
5 years ago
I just ran a test and got it to work with no problems.
Can you post a screenshot of your query in Design View please.
Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago
Sorry I uploaded one screenshot twice however you will see the data table and two views of the query. On the screenshot where the query has run what I am looking for is all of the products to show up including the ones with a 0 qtu. This query along with 4 others is used by a query that rolls up information for our customer. This is a test database using a snapshot of real data from our live database. I can take out the customer information and parse it down to only the information required to run this query and send you the database file if that helps.
Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago
Richard and Kevin, I added three new screenshots as the first ones were poor. Richard please delete the first four so they do not take up space. Thank you both for your interest and help. I suspect I am just missing some little nuance.
Thanks Evans
Kevin Robertson  @Reply  
          
5 years ago
Do you have any records where DOA is True and Qty is 0?
According to the screenshot you have 2 records where DOA is True and you are returning 2 records in your query results.
If you want to see ALL records you will need to remove the criteria (unless I'm misunderstanding you).
Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago

Evans Pridgen OP  @Reply  
    
5 years ago
Hi Kevin
No records that the DOA is true and the Qty is zero, however, I had an epiphany and was able to fix my issue. Granted I am sure you may have a better way but at least I dont have to manipulate the data to send to our customers.
I have created a select query that based on the DOA box being true it will generate a 1 or a 0 if false. From that, it becomes an easy crosstab query to generate the data including zero sums.
I have included the screenshots. Thanks for your input and I am always open to a better way!!
Thanks Evans

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 8/11/2026 7:47:21 AM. PLT: 1s