Solved

Invalid use of null in dlookup

Posted on 2006-07-05
6
496 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

919 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

17 Experts available now in Live!

Get 1:1 Help Now