Solved

Invalid use of null in dlookup

Posted on 2006-07-05
6
498 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 143

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 143

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 143

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

860 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