Solved

Invalid use of null in dlookup

Posted on 2006-07-05
6
495 Views
Last Modified: 2008-02-26
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
Comment
Question by:rgrguric
  • 3
  • 2
6 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045317

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
 

Author Comment

by:rgrguric
ID: 17045342
I put that in and I'm still receiveing the error same error message.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 17045396

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17045400
explanation: only VARIANT and OBJECT data types can get a NULL value, string, integer etc cannot (will raise the error you have)
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17045422
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
 
LVL 65

Expert Comment

by:rockiroads
ID: 17045425
wrap DLOOKUP with NZ is what Im supposed to have said, oops
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now