Results 1 to 3 of 3
  1. #1
    FuzzyLogician is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    2

    Filtered query look up

    Hey there,

    I have two tables, say customers and purchase orders. I am trying to write query that returns a list of customers based on a wild card purchase order search.


    (FYI, the query is being used in a VB.NET application)

    Code:
    SELECT Customers.WarehouseID AS Customers_WarehouseID, Customers.Name, PurchaseOrders.PurchaseOrder, PurchaseOrders.WarehouseID AS OBRs_WarehouseID 
    FROM Customers INNER JOIN OBRs ON Customers.[WarehouseID] = OBRs.[WarehouseID] 
    WHERE (((OBRs.OBR) Like '" & strPOFilter & "*'));
    
    This query almost works how I'd like it to, except in cases where a single customer has multiple purchase orders that begin the same way. So, for example, if customer "mike" has purchase orders "00554" and "00553", if you search for "00", mike will be returned twice. How can I modify the query to only return the customer once?

    Is it possible, or should I filter out repeated offenders in my code?

    Thanks for your assistance!

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Since you are including data from the Purchase Orders table (including Purchase Order itself), you are stuck as it will bring back all of the purchase orders.

    If you just want the unique customers then get rid of the fields from Purchase Orders and then include the Select Distinct at the start.

  3. #3
    FuzzyLogician is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    2

    Thumbs up

    Brilliant, thank you. I did not actually need the purchase order information, just the customer, so it worked perfectly.

    Much obliged.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-03-2010, 09:33 AM
  2. Can't keep dates filtered on my reports!
    By Mr. Coffee in forum Queries
    Replies: 5
    Last Post: 12-02-2010, 11:27 AM
  3. update query fon a filtered form HELP!
    By campanellisj in forum Queries
    Replies: 0
    Last Post: 11-12-2010, 09:08 AM
  4. Filtered Report
    By Desstro in forum Reports
    Replies: 3
    Last Post: 06-18-2010, 09:09 AM
  5. Filtered Print Query
    By Lupus in forum Queries
    Replies: 0
    Last Post: 08-17-2007, 02:50 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