Results 1 to 4 of 4
  1. #1
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138

    Queries with multiple conditions

    I am having some problems with syntax in a couple of queries with multiple conditions (they are being created in VBA):

    Code:
    strReportMachineSQL3 = "SELECT TBSource as Source, COUNT (TBSource) as qty INTO ChartTable FROM TurnBacks WHERE TBDate BETWEEN DateAdd('d', -30,Date()) AND Date() AND TBSource = '1' GROUP BY TBSource DESC;"
    
    strReportMachineSQL4 = "SELECT RRCAAera as Source, COUNT (RRCAArea) as qty INTO ChartTable2 FORM RCAData1 WHERE DefectDate Between DateAdd('d', -30, Date()) and Date() AND RRCAArea = '1' AND RRCAType = '1' GROUP BY RRCAArea DESC;"
    Do I need to do something different with all of the AND's? I think that I might be really close, but maybe a second set of eyes will help.

    Also, I am completely lost on one query. I will describe what I am trying to do.

    I need the list of the "Issues" for the "WorkArea" having the most "Issues" within the last 30 days and how many times each "Issue" occurs.



    I hope that this makes sense. Any help would be greatly appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    No, do not need to do anything special when criteria uses only AND or only OR operators. It's only when you mix them that parenthesizing becomes critical.

    What is the problem?


    Build a query that counts the issues grouped by work area and filtered for last 30 days. Then use that query as the source for a SELECT TOP n query.
    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.

  3. #3
    dccjr's Avatar
    dccjr is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Colorado Springs, CO
    Posts
    138
    I got the problem for the first part of my question. Fat fingers.

    As for the second part, I am not even sure where to begin. How would I structure it, and with which SQL commands?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Do those queries not provide results you expect? What happens?

    I don't see fields names Issues and Workarea in the sample queries. Did my suggestion in previous post help?
    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.

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

Similar Threads

  1. Multiple conditions in Access
    By engr_saud1 in forum Access
    Replies: 1
    Last Post: 04-03-2013, 06:18 AM
  2. Replies: 3
    Last Post: 08-01-2012, 10:56 AM
  3. Using iif for Multiple Conditions
    By kwilbur in forum Access
    Replies: 5
    Last Post: 12-30-2011, 01:52 PM
  4. iif statement with multiple conditions
    By ragsgold in forum Queries
    Replies: 7
    Last Post: 08-24-2011, 05:38 PM
  5. Expression with multiple conditions
    By techexpressinc in forum Queries
    Replies: 3
    Last Post: 06-19-2009, 08:33 PM

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