Hi all:
I'm having a slight logic problem that I cannot figure out. What the client wants is to find out if the email address is active or not, and since the DB may (and does) contain more than one status for opting out, I'm forced to return the values width-wise instead of like a table. The procedure works great for the first name only.
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors
I'm having a slight logic problem that I cannot figure out. What the client wants is to find out if the email address is active or not, and since the DB may (and does) contain more than one status for opting out, I'm forced to return the values width-wise instead of like a table. The procedure works great for the first name only.
Code:
Sub CreateMailList()
Dim Cat As ADOX.Catalog
Dim Con As ADODB.Connection
Dim RS As ADODB.Recordset
Dim numRecords As Long
Dim i As Long
Dim SQL As String
Dim Q As String
Set Cat = New ADOX.Catalog
Set Con = New ADODB.Connection
Set RS = New ADODB.Recordset
Q = Chr(34)
Sheets("Mail Chimp").Select
Range("A1").Select
Do
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Value = "" Then Exit Sub
s = ActiveCell.Text
i = 3
Con.Provider = "Microsoft.ACE.OLEDB.12.0" '"Microsoft.Jet.OLEDB.4.0"
Con.Open "Data Source=C:\Users\Repp-Web\Downloads\Agents2Email.accdb"
SQL = "SELECT qRealtors2OffAddZipEmail.RStat" & _
" FROM qRealtors2OffAddZipEmail " & _
"GROUP BY qRealtors2OffAddZipEmail.RStat, qRealtors2OffAddZipEmail.Email1 " & _
"HAVING (((qRealtors2OffAddZipEmail.Email1)=" & Q & s & Q & "));"
'Debug.Print SQL
RS.Open SQL, Con, adOpenDynamic, adLockOptimistic, adCmdText
Do While Not RS.EOF
s = RS(0).Value
[b]'here is the problem (I think)[/b]
If ActiveCell.Offset(0, i).Value = "" Then
ActiveCell.Offset(0, i).Value = s
i = i + 1
Else
i = i + 1
ActiveCell.Offset(0, i).Value = s
End If
RS.MoveNext
Loop
On Error Resume Next
RS.Close
Set RS = Nothing
Con.Close
Set Con = Nothing
Loop
End Sub
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors