How do I use to combo box in a form to display desired values?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tremonti92
    New Member
    • Feb 2008
    • 1

    How do I use to combo box in a form to display desired values?

    Hello..
    I have a table with a field name called 'Professions'. There are many same multiple values for this field, for example, there are many records with the value 'Doctor' under this field.

    Here are the values under this field in the table:
    Lawyer
    Lawyer
    Teacher Scientist
    Doctor
    Engineer
    Doctor
    Doctor
    Mechanic
    I want to make a form with a combo box where the combo box shows values under 'Professions', but I do not want the value 'Doctor' to be repeated more than once in the combo box... How can I do this??

    I have already tried creating a combo box query, but then the value 'Doctor' gets repeated more than once in the combo box because of the many records...

    When I open the combo box, I get these values:
    Lawyer
    Lawyer
    Teacher Scientist
    Doctor
    Engineer
    Doctor
    Doctor
    Mechanic
    but what i want to get after opening the combo box is:
    Lawyer
    Teacher Scientist
    Doctor
    Engineer
    Mechanic
    How do I do this? I hope I've made myself clear...
  • Stewart Ross
    Recognized Expert Moderator Specialist
    • Feb 2008
    • 2545

    #2
    Originally posted by tremonti92
    Hello..
    I have a table with a field name called 'Professions'. There are many same multiple values for this field, for example, there are many records with the value 'Doctor' under this field.

    I want to make a form with a combo box where the combo box shows values under 'Professions', but I do not want the value 'Doctor' to be repeated more than once in the combo box... How can I do this??
    Hi. In the rowsource property for the combo change the existing table reference or query to read like this, where [your table name] is the real name of the table or query holding the professions field:

    Code:
    SELECT [your table name].[professions] FROM [your table name]GROUP BY [your table name].[professions] ORDER BY [your table name].[professions];
    If you used the Access wizard for creating the combo box you could achieve the same thing by editing the rowsource property after the wizard created it. From the graphical query editor by selecting View, Totals (which does the Group By bit) and selecting Ascending in the order row.

    Cheers

    Stewart
    Last edited by Stewart Ross; Feb 15 '08, 03:07 PM. Reason: clarification of edit after wizard

    Comment

    Working...