Yes, you are right. But, for instance, if I run a query as this: SELECT
Country, Province, City, PostCode FROM tblPostCodes and I then, after
assigning the results to a recordset, I want to populate form controls
(drop down lists, one for data from each column) with appriopriate data I
need to get a list of unique countries from the recordset - I only want
one name of each country appear in a drop down list with countries. I
could of course write a separate query for each column but I don't want to
do this for performance reasons - I'd have than query a database for a new
list of provinces, cities, etc when user selects a different country in a
country drop down list.
For this I use:
Private Function GetProvinceList(ByRef mrsDataSet As ADODB.Recordset)
Dim mcolProvinceDistinctNames As New Collection
Dim mvCollectionItem As Variant
On Error Resume Next
Do
mcolProvinceDistinctNames.Add mrsDataSet![Province],
CStr(mrsDataSet![Province])
mrsDataSet.MoveNext
Loop Until Not mrsDataSet.EOF
On Error GoTo 0
But I thought there is a better way to do this.
U¿ytkownik "Bob Phillips said:
Surely, you are already querying the database to get a recordset? What I
am saying is to change the query to only return distinct records.
--
HTH
Bob