Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup and Null value 1

Status
Not open for further replies.

edge70

Technical User
Aug 5, 2004
15
CA
Hi all, I have a button in a form that should send an email IF there's an email adress in the related table OR display a message box if not.
I find the email adress in an other table using DLookup but I always get an invalid null use error message, can someone help me with this please ?
Here is the code I have right now:
Code:
    Dim emailAdress As String
    Dim emailSubject As String
    Dim emailContent As String
 
    emailAdress = DLookup("Courriel", "Table_Participants", "ID_Participant = " & Forms!Formulaire_Inscriptions!Participant)
    emailSubject = "Confirmation blabla"
    emailContent = "Ceci est pour blabla"

    If emailAdress.Value Is Null Then
       MsgBox "Le participant n'a pas d'adresse de courriel dans nos dossiers"
        Else
            stDocName = "Empty_Report"
           DoCmd.SendObject acSendNoObject, stDocName, acFormatHTML, emailAdress, , , emailSubject, emailContent, True
       ZT_DateConfirmation.SetFocus
       ZT_DateConfirmation.Text = Date
    End If
 
if nz(DLookup("Courriel", "Table_Participants", "ID_Participant = " & Forms!Formulaire_Inscriptions!Participant),0) = 0 then
msgbox ......
exit sub
endif
 
Replace this:
Dim emailAdress As String
with this:
Dim emailAdress As Variant

and this:
If emailAdress.Value Is Null Then
with this:
If IsNull(emailAdress) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried Orna's tip but for some reason I ended with an invalid operator error so I tried PH's one and this part works just fine now.

I still have a little glitch: the email address I retreive has changed, it now displays "syl@hotmail.com#mailto:syl@hotmail" instead of the regular email adress that I have in that field.

Someone has a clue ?


 
Problem solved.
The problem was in the test field of my table :-(

Thanks again for your help, it's greatly appreciated.

Regards

Syl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top