Results 1 to 10 of 10
  1. #1
    PinkDuster's Avatar
    PinkDuster is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2017
    Location
    Cleveland area
    Posts
    65

    ComboBox Returns Duplicates of Products -- I only want to see one of each

    I have a sales and inventory database (have discussed DB Design in the appropriate forum here) for which I now have two related tables: tblProducts and tblPricing. There are wholesale and retail prices for each product that are not related by a formula, so I split the original table. The order form has a subform for the order details, which includes a combobox for the sales person to select a product. However, now there are duplicate products, I think for each of the two types of pricing.

    I wanted to select a product, then use the next box for PriceType to be able to select the correct price. Is there something I am missing?

    Click image for larger version. 

Name:	Duplicates.png 
Views:	20 
Size:	44.6 KB 
ID:	31847
    Last edited by PinkDuster; 12-31-2017 at 08:33 AM. Reason: add different image

  2. #2
    Join Date
    Apr 2017
    Posts
    1,687
    There are more tables, are there? As you have in your post added a picture of Orders for, there is an table tblOrders or something like this?. And as Orders form looks like it has a subform for order rows, there must be a table like tblOrderRows too. Is it? What is the structure of this table?

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,991
    Difficult to do more than guess without seeing your data and you've removed the screenshot so I'm double blind.

    First I would suggest changing the combo row source to SELECT DISTINCT....

    BTW I don't understand why you have 2 separate tables for the 2 prices.
    Why not just 2 fields in the same table?

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,742
    Pinkduster,

    Perhaps you could lead us through a couple of examples to show more of the context involved in your process(es).
    Also you could show us a jpg of your current tables and relationships. Without such info, readers are just guessing at what you have and what you need.

  5. #5
    PinkDuster's Avatar
    PinkDuster is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2017
    Location
    Cleveland area
    Posts
    65
    There are: tblOrders, tblOrderDetails, and tblCustomers also. The OrderDetails table includes fields for OrderID, ProductID, ProductDescription, SoldAsPrice, Qty, PriceType.

  6. #6
    PinkDuster's Avatar
    PinkDuster is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2017
    Location
    Cleveland area
    Posts
    65
    I started with the two different prices in the same table, but couldn't make that work. It was recommended that I normalize the data by separating the different pricing into a separate table.

  7. #7
    PinkDuster's Avatar
    PinkDuster is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2017
    Location
    Cleveland area
    Posts
    65
    Attached shows the tables and relationships.

    Click image for larger version. 

Name:	TableRelationships.png 
Views:	21 
Size:	28.9 KB 
ID:	31849
    Last edited by PinkDuster; 12-31-2017 at 09:09 AM. Reason: Fix attachment

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,991
    Ok you've now fixed both images.
    What is the row source sql for the combo box which has duplicates?
    Have you tried using SELECT DISTINCT to get unique records yet?

  9. #9
    Join Date
    Apr 2017
    Posts
    1,687
    The RowSource of combo cbbProductID must be something like:

    Code:
    "SELECT prod.ProductID, prod.Description FROM tblProducts AS prod 
    WHERE prod.ProductUpdatedOn = (SELECT MAX(prod0.ProductUpdatedOn) FROM tblProducts AS prod0 WHERE prod0.ProductID = prod.ProductID AND prod0.LastUpdated <= " & Me.txtfkOrderID & ")"
    When this query returns double set of rows, then you must have double rows in table tblProducts too - which is impossible with ProductID being a single primary key.
    NB! You have to update the combos RowSource by some form event, p.e. by Orders form OnCurrent or AfterUpdate event, as you can't use a formula for SQL string as control's property.

    And you don't need a field SoldAsPrice in table tblOrderDetails. With your current tables setup you can always calculate it from tblProductPrices as a latest price of selected type for given product with LastUpdated <= OrderDate

  10. #10
    PinkDuster's Avatar
    PinkDuster is offline Advanced Beginner
    Windows 7 64bit Access 2013 32bit
    Join Date
    Aug 2017
    Location
    Cleveland area
    Posts
    65
    Yes, I did, and it worked! Thank you!

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

Similar Threads

  1. Combobox returns multiple fields but not the ID number
    By pattrickcolin in forum Queries
    Replies: 5
    Last Post: 06-03-2014, 12:37 PM
  2. Replies: 1
    Last Post: 06-24-2013, 05:14 PM
  3. Replies: 8
    Last Post: 04-24-2012, 01:05 PM
  4. Replies: 2
    Last Post: 04-10-2012, 12:30 AM
  5. Query returns duplicates
    By RobRay in forum Queries
    Replies: 3
    Last Post: 10-26-2010, 01:38 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