Hey, I am trying to select all of the e-mail addresses in a table and display them without duplicates. The table name is "Signed Leases", the column name is "Email" and i am trying to place it in "text4". I receive an error message "Compile Error : Expected Array" at the "emails(count) =" line. This is the code.
Rich (BB code):
Private Sub Command3_Click()
Dim db As DAO.Database
Dim strWhere As String
Dim numberOfRecords As Integer
Dim count As Integer
Dim count2 As Integer
Dim count3 As Integer
Dim label As String
Dim emails As String
emails = Array()
Dim emailsNoDuplicates As String
emailsNoDuplicates = Array()
Dim duplicate As Boolean
Dim x As Integer
x = 0
label = ""
Set db = CurrentDb ' select current database
'numberOfRecords = DCount("[ID]", "Signed Leases") 'count number of records
For count = 0 To 50 'first loop through
strWhere = "ID = " & count + 1
If DLookup("", "Signed Leases", strWhere) <> "" Then 'if the cell is not empty, populate the first array
emails(count) = DLookup("[Email]", "Signed Leases", strWhere)
duplicate = False 'reset duplicate to false
For count2 = 0 To count - 1 'second loop for checking only previous entries
If emails(count) = emails(count2) Then 'if the email has already been looked at, trigger duplicate to true
duplicate = True
End If
Next count2
If duplicate <> True Then 'if it is not a duplicate, populate a new array with the email
emailsNoDuplicates(x) = emails(count2)
x = x + 1
End If
End If
Next count
Text4.SetFocus
For count3 = 0 To x - 1
label = label & emailsNoDuplicates(count3) & "; "
Text4.Text = label
Next count3
End Sub
[/code]
I am not sure why i receive this error as the array is defined and i receive the error as it tries to populate the first array.
Thanks in advance for any help!