Invalid use of Null (Error 94)

Sparky

Registered User.
Local time
Today, 12:29
Joined
Jan 17, 2000
Messages
20
I have this code in my database to send automated e-mails:-

Sub sendmail()

Dim rsEmail As DAO.Recordset

Dim strEmail As String

Set rsEmail = CurrentDb.OpenRecordset("Master Student Database")

Do While Not rsEmail.EOF

strEmail = rsEmail.Fields("EmailAddress").Value

DoCmd.SendObject , , , strEmail, , , rsEmail.Fields("Matric No").Value, "This is an automated e-mail. Please do not respond", False

rsEmail.MoveNext

Loop
Set rsEmail = Nothing
End Sub

Does anyone know how to change my code so that if there isn't an e-mail address don't send an e-mail?

Many thanks
 
I would try changing this:
strEmail = rsEmail.Fields("EmailAddress").Value

DoCmd.SendObject , , , strEmail, , , rsEmail.Fields("Matric No").Value, "This is an automated e-mail. Please do not respond", False

To this:
strEmail = rsEmail.Fields("EmailAddress").Value
Iif(len(strEmail) > 0 then
DoCmd.SendObject , , , strEmail, , , rsEmail.Fields("Matric No").Value, "This is an automated e-mail. Please do not respond", False
End if
 
Thankyou for your response but I am getting an error:-

Compile Error: Syntax error

Any ideas?

Many thanks

[This message has been edited by Sparky (edited 05-31-2001).]
 

Users who are viewing this thread

Back
Top Bottom