.Recipients.Add

  • Thread starter Thread starter Chip
  • Start date Start date
C

Chip

Hey Everyone,

I have a script running in my database that creates and sends an
Email. I have several lines in my code that go like this...

..Recipients.Add (Me![Text123]) 'Where Text123 stores the email address
for the person

One of my fields in my database is optional. Most are not, so the
above line works find. But if I do not have an email address for a
particular person, the above line errors out becaue it has nothing to
put in.

So I thought I might be able to use Nz like this...

..Recipients.Add (Nz(Me![Text123]), "")

Access doesnt like this. I can insert a dummy email address in the
Null spot so it reads as

..Recipients.Add (Nz(Me![Text584], "(e-mail address removed)")

Ideas?

chip
 
Don't bother executing that line when you don't have a value:

If Len(Me![Text123] & vbNullString) > 0 Then
.Recipients.Add Me![Text123]
End If
 
Chip -

You should test for a null value before adding it to the list. Something
like this:

If not isnull(Me![Text123]) Then
.Recipients.Add (Me![Text123])
End If
 
Back
Top