Results 1 to 7 of 7
  1. #1
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283

    removing multiples of an order number

    I have data that looks like this
    Click image for larger version. 

Name:	Capture.PNG 
Views:	6 
Size:	5.4 KB 
ID:	22636

    What I am trying to do is not count any record that has multiple orders.



    The main portion of the order number is the first 6 characters ex: WC6939
    If there is only one order in the group the number would be WC6939001
    If there are multiple orders it would show like order number WC6969 above WC6969001, WC6969002, WC6969003

    What I want to do is not return any records if they have multiples so basically using the data above WC6969001, 002 and 003 would not return

    I tried using IIf(Count([MAIN_ORDER]=1),1,0) but that didn't work.

    Any help would be appreciated

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    The following will return only the 001 records:

    SELECT * FROM table where Val(Mid([fieldname], 7))=1;

    If you don't even want the 001 records for orders that have multiples:

    SELECT * FROM table WHERE NOT Order IN (SELECT Order FROM table WHERE Val(Mid([fieldname],7)) > 1);
    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
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    Is there a way to do this using the builder from a column within a query?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    Don't really understand the question. Enter expressions in the Criteria row of query designer.
    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.

  5. #5
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    Maybe I am asking it wrong. I tried entering it in the criteria for the field but it throws a subquery error.

    This is what my query currently looks like


    Click image for larger version. 

Name:	Capture.PNG 
Views:	5 
Size:	20.6 KB 
ID:	22638

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    My suggestions are not aggregating - there is no grouping.
    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.

  7. #7
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    I figured it out this way

    Code:
    SELECT *
    FROM (SELECT ORDER_DETAIL.REGION, Left([ORDER_DETAIL]![ORDER NUMBER],6) AS MAIN_ORDER, Count([MAIN_ORDER]) AS UNIQUE_ORDERS, ORDER_DETAIL.VOSS, (Day([ORDER DATE])-1)\7+1 AS Week
    FROM ORDER_DETAIL INNER JOIN x_Employee_list ON ORDER_DETAIL.VOSS = x_Employee_list.VOSS_Name
    GROUP BY ORDER_DETAIL.REGION, Left([ORDER_DETAIL]![ORDER NUMBER],6), ORDER_DETAIL.VOSS, (Day([ORDER DATE])-1)\7+1, ORDER_DETAIL.[NEW BUS TYPE], Year([ORDER DATE]), Month([ORDER DATE])
    HAVING (((ORDER_DETAIL.REGION)="CENTRAL") AND ((ORDER_DETAIL.[NEW BUS TYPE])="XTI") AND ((Year([ORDER DATE]))=Year(Now())) AND ((Month([ORDER DATE]))=Month(Now())-1)))  AS [%$##@_Alias]
    WHERE [UNIQUE_ORDERS]=1;

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

Similar Threads

  1. Replies: 4
    Last Post: 07-15-2014, 11:45 AM
  2. Replies: 3
    Last Post: 07-31-2013, 08:46 PM
  3. Autogenerated Purchase Order Number
    By burrina in forum Forms
    Replies: 2
    Last Post: 12-15-2012, 10:37 PM
  4. display order number
    By Hopeless in forum Forms
    Replies: 3
    Last Post: 08-25-2012, 06:46 PM
  5. Northwind Purchase Order Number
    By jpl85716 in forum Access
    Replies: 3
    Last Post: 09-29-2010, 12:53 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