Probably cos your DLookup statement doesn't make sense. You have incorrect
"'s and, I suggest you use the Nz function to make sure the system doesn't
bomd-out if DLookup can't find a match.
Try changing it to:
SendTo = Nz(DLookup("Email", "Personel", "Initials = '" & Me.fAssignedTo &
"'"), "")
(where '" = exagerated, ' ", and "'" = " ' ")
I would then check SendTo to make sure it doesn't = ""
I also note that later on you change the value of SendTo without using the
DLookup value?
Cheers.
BW
"bymarce" wrote:
> Why isn't this Dlookup working? I want this code to look up an email address
> in he personel table based on the initials used in an unbound combo box.
> When I run it it says "invalid use of null". Thanks.
> Marcie
>
> Private Sub Email_Work_Click()
>
> Dim SendTo As String
> SendTo = DLookup("Email", "Personel", "Initials = ""Me.fAssignedTo""")
> Dim strWhere As String
> If Me.FilterOn Then
> strWhere = Me.Filter
> End If
> Debug.Print strWhere
>
> Dim MySubject As String, MyMessage As String
> SendTo = Mail
> MySubject = Me.MLO
> MyMessage = "Please complete the following tests for " & Me.MLO & "."
> DoCmd.SendObject acSendReport, "rptWorkAssignments", , SendTo, , ,
> MySubject, MyMessage, False
>
> End Sub
|