Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

.Recipients.Add

0 views
Skip to first unread message

Chip

unread,
Dec 23, 2009, 11:58:09 AM12/23/09
to
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

Douglas J. Steele

unread,
Dec 23, 2009, 12:10:40 PM12/23/09
to
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

--
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...

Daryl S

unread,
Dec 23, 2009, 12:44:01 PM12/23/09
to
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
--
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
> .
>

0 new messages