Solved

DSum cancelling on Error 94, Invalid use of Nulls

Posted on 2011-02-17
3
812 Views
Last Modified: 2012-05-11
I am using the following stetment to get a total number of patients in my table.

AllPatients = DSum("[Patients]", wkTable, wkSumClientWhere)

When there are no patients matching the criterion it cancels with an error 94, invalid use of nulls.  It works without fail if there is/are matching patient(s).

How can I set this up to trap that particular error and have the value of AllPatients be zero if there are no matches in the table.
 

0
Comment
Question by:mlcktmguy
  • 2
3 Comments
 
LVL 75
ID: 34920959
Where is the definition of wkSumClientWhere   and wkTable ... show that part of the code.

mx
0
 
LVL 1

Author Comment

by:mlcktmguy
ID: 34921041
I used a debug to display the contents of the two variable when this statement cancelled and when the Dsum was successful.  The contents were:

wkTable=  tbl_365Day_Counts_Final
 
wkSumClientWhere =  ( ([ClientID]  IN (Select[ClientID] from tblWkRptClients))  And ([LinkDate] Between #3/1/1930# and #3/3/2010#) )

The format of the statements is OK the issue only occurs when there is no matching criterion in the program.

For now I've set it up like this:

AllPatients =0
on error resume next
AllPatients = DSum("[Patients]", wkTable, wkSumClientWhere)
on error go to 0

It works and the end result is a zero in AllPatients if no patients match the criterion.  I just thought there might be a better more general way of handling it.


0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 50 total points
ID: 34921226
Interesting WHERE clause for DSum() ... sub query.  Never tried that.   But if you have it working ... guess I would go with that.

mx
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

895 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

11 Experts available now in Live!

Get 1:1 Help Now