Populate Access ListBox with Distinct/Unique Values

Copper Contributor

I'm a CS student in my 4th year, my professor wont grade my assignment because i didn't populate a ListBox correctly (I got a 10/200 but i have an option to turn in 1 revision). The ListBox named "lstCateName" displays a property type (castle, villa, manor) from a table named "tblProperty" on a form called "frmType".

 

My problem is with getting the ListBox to display only one of each Property type (Only 3 options instead of many same repeating options like in the image below)

 

1.png

 

I need it to only display 3 options, "castle", "villa", and "manor". I have looked endlessly for the solution to no avail. There are some tutorials out there that focus on Excel and use VBA which i am not familiar with nor do i know how to implement into an Access Database.

 

[edit]

This is what i currently have in the property sheet for the ListBox under the Row Source

SELECT DISTINCT tblProperty.PropertyID, tblProperty.PropertyType FROM tblProperty ORDER BY tblProperty.[PropertyType];

The PropertyID property is hidden form what i recall.

 

1 Reply

@globz 

 

Drop the tblProperty.PropertyID field so it looks like this:

SELECT DISTINCT tblProperty.PropertyType FROM tblProperty ORDER BY tblProperty.[PropertyType];