Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

Invalid use of null in dlookup

I keep getting an error message saying invalid use of null... please help.

Dim dSubject As String
Dim dResponsibility As String
dSubject = DLookup("designsubject", "tblpart", "isnull(DesignRespond) And DateDiff('d', DesignStartDate, Now()) <= 3")
dResponsibility = DLookup("designresponsibility", "tblpart", "DesignRespond Is Null And DateDiff('d', DesignStartDate, Now()) <= 3")
If Not IsNull(dSubject) Then
    DoCmd.SendObject acSendNoObject, , acFormatHTML, "rgrguric@yahoo.com", , , "Employee has not responded for DESIGN responsibility, please review!!!", "User " & dResponsibility & " has not responded for DESIGN responsibility on " & dSubject & ".", False
End If

Thanks,
0
rgrguric
Asked:
rgrguric
  • 3
  • 2
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:

Dim dSubject As String
Dim dResponsibility As String
dSubject = DLookup("designsubject", "tblpart", "DesignRespond is null And DateDiff('d', DesignStartDate, Now()) <= 3")
dResponsibility = DLookup("designresponsibility", "tblpart", "DesignRespond Is Null And DateDiff('d', DesignStartDate, Now()) <= 3")
If Not IsNull(dSubject) Then
0
 
rgrguricAuthor Commented:
I put that in and I'm still receiveing the error same error message.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:

Dim dSubject As variant
Dim dResponsibility As variant
dSubject = DLookup("designsubject", "tblpart", "DesignRespond is null And DateDiff('d', DesignStartDate, Now()) <= 3")
dResponsibility = DLookup("designresponsibility", "tblpart", "DesignRespond Is Null And DateDiff('d', DesignStartDate, Now()) <= 3")
If Not IsNull(dSubject) Then
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
explanation: only VARIANT and OBJECT data types can get a NULL value, string, integer etc cannot (will raise the error you have)
0
 
rockiroadsCommented:
wrap DLOOKUP with ""


Dim dSubject As String
Dim dResponsibility As String


dSubject = NZ(DLookup("designsubject", "tblpart", "DesignRespond is null And DateDiff('d', DesignStartDate, Now()) <= 3"),"")
dResponsibility = NZ(DLookup("designresponsibility", "tblpart", "DesignRespond Is Null And DateDiff('d', DesignStartDate, Now()) <= 3"),"")

Now u can check for empty string

if dSubject = "" then
    msgbox "No Subject"
endif


U can use NZ to give a default value instead of "" instead
0
 
rockiroadsCommented:
wrap DLOOKUP with NZ is what Im supposed to have said, oops
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now