Results 1 to 11 of 11
  1. #1
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23

    Generating a Query based on two factors

    All,



    I'm looking to generate a list of what I call [Job Orders] - a 7 digit number assigned to a specific group of assets based on when they arrive. However, I only want the results to be the [Job Orders] whose assets are all recorded as "Shipped" under the [Asset Status] field.

    Any thoughts?

    Also - am I using the brackets and quotes correctly? Brackets are for fields and quotes are for the drop-down selection in that field.

  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
    Don't understand the issue. Appears to be a simple SELECT query with filter criteria.
    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
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    You may very well be correct - I just do not understand what it is that I am supposed to do. The struggle that I am having is that one particular Job Order Number will be applied to as many as 2,000 assets. Each of those 2,000 assets has a status. I'm looking to find a way to generate a list of job numbers where all the assets have "Shipped" as their status; there are six statuses that in play.

  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
    Okay, if I understand:

    You have JobOrders. JobOrders have associated assets. Each asset has its own status. You want a listing of JobOrders where for each all their assets are 'shipped'? That does get a little tricky. Something like:

    SELECT * FROM OrdersTable WHERE NOT OrderID IN (SELECT OrderID FROM OrderAssets WHERE [Asset Status]<>"Shipped");
    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
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    Thank you for your quick response.

    Here is my SQL text.

    SELECT * FROM [Database] WHERE NOT [Job Order] IN (SELECT [Job Order] FROM [DATABASE] WHERE [Asset Status]<>"Shipped");


    Have I interpreted your response correctly? When I RUN this, Access prompts me by asking what Job Order I want.

    I'm sorry that I am not up to speed with the rest of the community - I only know a small amount.

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    generate a list of what I call [Job Orders]
    According to your first post, [Job Orders] has an "s".

    SQL modified:
    SELECT * FROM [Database] WHERE NOT [Job Orders] IN (SELECT [Job Orders] FROM [DATABASE] WHERE [Asset Status]<>"Shipped");



    Edit:
    BTW, "Database" is a reserved word in Access and shouldn't be used for object names.
    Should only use letters, numbers and the underscore in object names. NO spaces, punctuation or special characters (except the aforementioned underscore)

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why is the same table name referenced in both SELECT statements? Aren't two tables involved?

    Table named Database is not very informative name.
    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.

  8. #8
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    Very good eye! What a detail to spot. But, unfortunately the error in typing was in the first post - the field title is singular.

    I agree with your followup - but, I am not the original architect of our database.

  9. #9
    LeadTechIG is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2014
    Posts
    23
    We only utilize one table - and its called simply our "Database". I've been informed on multiple occasions that we are using Access in a manner deemed incorrect.

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664

    Can you post your dB with 10 - 20 records? Change any sensitive data....

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Okay, should still work, it does in my test in my db.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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. Query Generating different results
    By jj1 in forum Access
    Replies: 4
    Last Post: 06-03-2014, 09:33 AM
  2. Generating a report based upon a condition
    By CaveCanem in forum Programming
    Replies: 2
    Last Post: 03-27-2014, 01:56 PM
  3. Replies: 5
    Last Post: 05-05-2012, 10:11 AM
  4. Replies: 1
    Last Post: 03-01-2012, 04:35 AM
  5. Replies: 4
    Last Post: 07-27-2011, 12:42 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