Results 1 to 9 of 9
  1. #1
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568

    How to avoid duplicates in combobox?

    Hi,

    I tried to implement into my model solution from here:


    https://www.techonthenet.com/access/...values2013.php

    but still i have duplicates rows in my combobox:

    Click image for larger version. 

Name:	Bez tytu?u.png 
Views:	25 
Size:	75.2 KB 
ID:	30114

    My rowsource for this combobox is query where i am taking Company name, company number and companyID.
    The last one in the most impoirtant because it is a foreign key in my summary table.
    So user should take company name and aotumatically i would have CompanyID which is inserting into my summary table.

    Query from tbl_slow_spolki as rowsource of combobox:

    Click image for larger version. 

Name:	Bez tytu?u2.png 
Views:	25 
Size:	25.9 KB 
ID:	30115

    my tbl_slow_spolki table:

    Click image for larger version. 

Name:	Bez tytu?u3.png 
Views:	25 
Size:	21.5 KB 
ID:	30116

    as you can see i have duplicates right here so in my query there are duplicates rows!

    It is a way to avoid this via combobox? Or maybe i shoud change my table source?

    Thank you for your help and support!
    Best Wishes,
    Jacek
    Attached Thumbnails Attached Thumbnails Bez tytu?u.jpg  
    Last edited by jaryszek; 08-28-2017 at 11:42 PM.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I'd just pull from tbl_Company, which presumably doesn't have duplicates. To use the same source:

    SELECT DISTINCT Field1, Field2, Field3
    FROM TableName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    gunitinug is offline Novice
    Windows 10 Access 2007
    Join Date
    Aug 2017
    Posts
    23
    Hey jary.

    You can set property called 'limit to list' to on.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Quote Originally Posted by gunitinug View Post
    You can set property called 'limit to list' to on.
    That wouldn't stop duplicates in the row source, it would just prevent you from entering something that didn't exist the row source.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Thank You Guys for your help!

    Sorry my friends, I added mistakenly picture with my old database.
    Current picture for relationships is:

    Click image for larger version. 

Name:	current.png 
Views:	12 
Size:	34.0 KB 
ID:	30123

    So in my tbl_slowSpolki i have duplicates rows and that is why in my combobox there are not unique values...

    What can i do here?

    Maybe i should create a tab le with unique companies name and numbers - separately from others:

    Click image for larger version. 

Name:	example.png 
Views:	12 
Size:	38.3 KB 
ID:	30124

    Now table tbl_slow_spolki is a junction table - bridge connecting tbl_ComaponyNames and tbl_Reminders_employee.
    What do you think about this solution?

    Best Wishes,
    Jacek

  6. #6
    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,848
    Review the use of DISTINCT in your SQL.
    DISTINCT will give unique values, no duplicates, BUT you must be specific in which field or combination of fields you are dealing with.

  7. #7
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Thank you Orange and glad to read you again,


    If you are looking for this model - there is a problem with relationship i think.

    I am creating combobox from tbl_CompanyNames.
    And now i have unique values - it is ok.

    But where can i put my tbl_CompanyNames_nr primary key ?
    User from this combobox will take for example number 5 and so what?

    I would like to take tbl_slow_spolki.ZleceniodawcaID in order to put it into tbl_Braki into Zleceniodawca_nr_FK field.
    How to create a form which will allow to do that?
    In other words the main point here is to put Zleceniodawca_nr_FK in tbl_Braki.
    If i will write here for example 5, i will be knowing that in tbl_slow_spolki there is company number 5 and for example RemindersID = 3.
    How can i achive this?

    I think this is a problem with my model again :/
    Do you understand me?

    Please help,

    Best Wishes,
    Jacek

  8. #8
    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,848
    Generally, if you build a combo with unique values, you may have 2 fields in the combo.
    Let's say there are CompanyNumber and CompanyName. You select Distinct to prevent any duplicates.
    And, for the combo display you show size 0;1 where 0 represents no length for CompanyNumber, and 1 shows length for display of CompanyName. However, your bound column is CompanyNumber and that is the value that gets stored in another table or control as per your needs.

    Here is lots of info on comboboxes.

    Good luck

  9. #9
    jaryszek is offline Expert
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2016
    Posts
    568
    Thank you orange,

    i think that problem is within my model. Combobox is ok...

    I am closing the topic and creating new one.

    Best Wishes,
    Jacek

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

Similar Threads

  1. Replies: 6
    Last Post: 04-08-2016, 07:32 AM
  2. Replies: 3
    Last Post: 01-18-2016, 01:55 PM
  3. avoid multiple queries
    By slimjen in forum Queries
    Replies: 4
    Last Post: 06-29-2014, 08:49 PM
  4. how to avoid #Div/0! error
    By lugnutmonkey in forum Queries
    Replies: 6
    Last Post: 04-17-2013, 01:58 PM
  5. Hi, How do we avoid repeated records?
    By radicrains in forum Queries
    Replies: 11
    Last Post: 11-04-2010, 03:00 AM

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