Hello everyone, hope someone can help me.
I'm using the following code to extract e-mails from my database, compile them into a string and use that in outlook (not spam) the only problem is that I need to exclude entries that are blank.
The original bit of code had this in the compile line (stTO <> "", ";", "") instead of (stTO <> "", ";", "") but never worked, kept bugging out.
What would be the best way to exclude blank fields???
Dim rst As DAO.Recordset
Dim stSQL As String
Dim stTO As String
stSQL = "clients"
Set rst = CurrentDb.OpenRecordset(stSQL)
With rst
.MoveFirst
Do While Not .EOF
stTO = stTO & IIf(stTO <> "", ";", "") & .Fields("E-Mail Address")
.MoveNext
Loop
End With
DoCmd.SendObject acSendNoObject, , , , , stTO, "Message Header", , True
End Sub
Cheers Everyone
I'm using the following code to extract e-mails from my database, compile them into a string and use that in outlook (not spam) the only problem is that I need to exclude entries that are blank.
The original bit of code had this in the compile line (stTO <> "", ";", "") instead of (stTO <> "", ";", "") but never worked, kept bugging out.
What would be the best way to exclude blank fields???
Dim rst As DAO.Recordset
Dim stSQL As String
Dim stTO As String
stSQL = "clients"
Set rst = CurrentDb.OpenRecordset(stSQL)
With rst
.MoveFirst
Do While Not .EOF
stTO = stTO & IIf(stTO <> "", ";", "") & .Fields("E-Mail Address")
.MoveNext
Loop
End With
DoCmd.SendObject acSendNoObject, , , , , stTO, "Message Header", , True
End Sub
Cheers Everyone