Invail use of null

sdawson

Registered User.
Local time
Today, 18:10
Joined
Apr 22, 2003
Messages
165
I'm using the following to e-mail a report from control button on form.
The purpose of the it then else is to open Outlook with the e-mail address of the recipient if stremail contains a value and open it with the recipient blank if stremail is empty.
All I get is the error message "Invaild use of null" if stremail is empty. If stremail has a value it's OK.

Any ideas or threads to follow?

++++++++++++++++++++++++++++++++++++++++++++++

Dim stDocName As String
Dim stremail As String

stDocName = "email report"

DoCmd.OpenReport stDocName, acViewPreview, , "[ID]=" & Forms![aform]![ID]
stremail = Reports![email report]![emailaddress]

If IsNull(Me![emailaddress]) Then

DoCmd.SendObject acReport, stDocName, acFormatRTF, , " cc address.co.uk ", ,
"Message content", "Some message", True
Else
DoCmd.SendObject acReport, stDocName, acFormatRTF, stremail, "cc address.co.uk", ,
"Message content ", " Some message ", True
End If
MsgBox "E-Mail has been sent"
DoCmd.Close , stDocName, acSaveNo

++++++++++++++++++++++++++++++++++++++++++++++

Ta
 
sdawson said:
If IsNull(Me![emailaddress]) Then

DoCmd.SendObject acReport, stDocName, acFormatRTF, , " cc address.co.uk ", ,
"Message content", "Some message", True
Else
DoCmd.SendObject acReport, stDocName, acFormatRTF, stremail, "cc address.co.uk", ,
"Message content ", " Some message ", True
End If


Some arguments just are not optionak i.e. you are required to offer an email address to send it to. If you need it to send either way then move the "cc address.co.uk" part in the first address into the argument (i..e that used by the strEmail in the ELSE part).

And please use the [CODE] [/CODE] tages when posting code. :cool:
 
Re: Re: Invail use of null

Mile-O-Phile said:



And please use the [CODE] [/CODE] tages when posting code. :cool:

What does that do?
 
I understand what u say about the optional argument but what this
Code:
 /[CODE] tages stuff?
 

Users who are viewing this thread

Back
Top Bottom