Results 1 to 6 of 6
  1. #1
    Michellephant is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2015
    Posts
    3

    Lightbulb Query Issues - Need field to be 0 instead of not displaying

    Hello,



    I am trying to make a query that includes 3 other queries. The primary key is customer number and I am trying to pull the sales for each customer by week, month, and quarter. If a customer has not purchased anything it does not display at all. Also, if they purchased something in the quarter or month but not in the past week it doesnt display. I would like the sales for the week, month, or quarter to display 0 if no transactions were made. It is not feasible to add a record for each customer with "0" since this would be updated daily. Please help!

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    The best option is to use the Nz function, to display 0 if a field is Null:

    ColumnTitle:Nz([queryfieldname],0) as the field name in Query Design view.

  3. #3
    Michellephant is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2015
    Posts
    3
    Thank you for your reply. I put Nz([Current Month]![Orders],0) in the field of each, Current month being the Query name and Orders being the field but it is still not displaying 0's.

  4. #4
    darshit_goswami is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Posts
    29
    try:

    IIF(IsError([Current Month]![Orders]),0,[Current Month]![Orders])

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    Apply the period filter in a query then join that query to the Customers table using JOIN "Include all records from Customers ..."

    Another approach would need a dataset that has a record for each customer for each period so that when records are filtered for a period every customer will still show. Dummy records is one way and I understand why you reject it. So this gets a little difficult, especially because date periods are involved and the period filtering drives off of the order dates.These datasets can be generated with queries that include tables without JOIN clause which results in a Cartesian relation - every record of each table joins with every record of other table so the result is every possible combination of customer and something, in this case a date period. Then that query can be joined to the actual data table/query ("Include all records from {the Cartesian query} and only those from {table/query} that match") by linking on the common customerID and date fields.

    This same issue has been topic of numerous threads. Search on "Cartesian" as well as my username to narrow the results.

    Other alternatives:

    1. domain aggregate functions - I do this on one report to assure that I have an aggregate value 'record' displayed for every month of year even if there was no data in any month - each 'record' is really just a textbox with a DSum() expression that aggregates for each year/month - 12 textboxes

    2. VBA and temp tables

    Good Luck.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Michellephant is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2015
    Posts
    3
    Thank you so much! I didn't know I could change the join Properties to show all Records from the primary key so thats what was messing me up. Your answer combined with John_G's solved my problem! Also thanks to darshit_goswami for trying to help! You guys are AWESOME! I was searching for an answer the past couple days and decided to post, Im glad I did!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. summary field not displaying
    By DKP in forum Forms
    Replies: 2
    Last Post: 10-10-2014, 04:03 PM
  2. Multi-Field Search issues within Query
    By stiracerdude in forum Queries
    Replies: 3
    Last Post: 10-14-2012, 01:04 PM
  3. Calculation Field Issues
    By MintChipMadness in forum Access
    Replies: 7
    Last Post: 06-25-2012, 02:37 PM
  4. Replies: 1
    Last Post: 06-19-2012, 06:39 PM
  5. Form field not displaying in query
    By Valeda in forum Queries
    Replies: 2
    Last Post: 05-05-2006, 10:08 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums