Results 1 to 8 of 8
  1. #1
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95

    Force Combo Box to offer unique values from the table

    Hello there..
    How can I force my Combo to offer me only unique records from the source column in my data table ("Table1")?


    Below, please find database in ZIP.

    Click image for larger version. 

Name:	forum-06.jpg 
Views:	33 
Size:	194.5 KB 
ID:	30424

    Thanks.
    Attached Files Attached Files

  2. #2
    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,722
    In your view what exactly is a duplicate?

    To get unique values you can use the DISTINCT parameter on your combo Row source.

    Consider, John Smith from California, and John Smith from Idaho..... are these duplicates? If so, please explain.

  3. #3
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95
    Thanks for reply..

    AS you can see on the picture I've posted, John Smith from California, and John Smith from Idaho are two different records.. As both of them are named the same, it makes no sense for me to see last name Smith twice. Anyway, after I choose Smith in 2nd combo, I am going to choose California at last (third) combo..

    Imagine I have 35 Smiths and 5 other and mutually different last names (in total 40 records).. In that case I want second combo to offer me in total 6 rows (Smith + 5 other ones).

    Hope I have made myself clear in what i would like to have here.

  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,722
    The concept underlying what you are trying to achieve is called Cascading Combos.

    Here are some links to more info on Cascading combos.

    This pair is from DataPig. A little older but excellent example.
    http://www.datapigtechnologies.com/f...combobox1.html
    http://www.datapigtechnologies.com/f...combobox2.html

    From Paul http://www.baldyweb.com/CascadingCombo.htm

    You can google/youtube for more info.
    Good luck.

  5. #5
    Join Date
    Apr 2017
    Posts
    1,679
    Are combos at right to select person in form? In this case you'll be better of with a single combo!

    Create any record selection combo, p.e. cbbSelectPerson, and then edit it:
    Set RowSourceType property = 'Table/Query';
    Set RowSource property = 'SELECT tblPersons.ID, tblPersons.First_Name & " " & tblPersons.Last_Name & " (" & tblPersons.City & ")" AS PersonInfo ORDER BY 2';
    Set BoundColumn property = 1
    Set ColumnCount property = 2
    Set ColumnWidths property = '0;2.5'

    In form's OnCurrect event, set
    Me.cbbSelectPerson = Me.[ID]

    The combo displays selections like
    "John Malkovich (Boston)"
    "John Malkovich (Orlando)"

    and when combos events are set properly, selecting a row in combo displays selected person's info in form (and moving to another record updates the combo too).

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by orange View Post

    To get unique values you can use the DISTINCT parameter on your combo Row source.
    Like this:
    Code:
    SELECT DISTINCT [Table1].[Last_Name] FROM Table1 WHERE (([Table1].[First_Name])=[Forms]![frm_Main]![cbo_First_Name]) ORDER BY [Table1].[Last_Name];

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95
    Huge thanks! This is what I have been looking for! This works perfectly!

  8. #8
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 1
    Last Post: 03-17-2017, 04:19 AM
  2. Replies: 11
    Last Post: 09-03-2015, 11:12 AM
  3. Replies: 6
    Last Post: 10-10-2012, 05:08 AM
  4. force action at combo box
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 03-01-2012, 11:21 PM
  5. Replies: 5
    Last Post: 01-18-2012, 12:32 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