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], "any...@anywho.org")
Ideas?
chip
If Len(Me![Text123] & vbNullString) > 0 Then
.Recipients.Add Me![Text123]
End If
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Chip" <chip.f...@gmail.com> wrote in message
news:3b747bf0-b32f-4800...@r5g2000yqb.googlegroups.com...
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
--
Daryl S
"Chip" wrote:
> 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], "any...@anywho.org")
>
> Ideas?
>
> chip
> .
>