Select unique record SQL-VBA
Thanks in advance for your help.
I have an Access database and the record is like this:
Date Country Type Index
1.1 Canada A
2.1 Canada A
3.1 Canada A
4.1 Canada A
5.1 Canada A
6.1 Canada A
1.1 US A
2.1 US A
3.1 US A
4.1 US A
5.1 US A
6.1 US A
......
How can I select the unique country names from the database, If the select clause is correct as following, and I would like to fill an array with the country name, the codes are as following, but there is problem with "varArray(i) = rec("Country")"
strSELECT = "SELECT DISTINCT Country"
strFROM = " FROM tblIndex "
strSQL = strSELECT & strFROM
Set rec = db.OpenRecordset(strSQL, dbOpenDynaset)
rec.MoveLast
rec.MoveFirst
ReDim varArray(1 To rec.RecordCount)
i = 1
Do While Not rec.EOF
varArray(i) = rec("Country")
rec.MoveNext
i = i + 1
Loop
Can anyone give me some advice?