Solved

DSum cancelling on Error 94, Invalid use of Nulls

Posted on 2011-02-17
3
815 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 - Microsoft MVP, Access and Data Platform) 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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 …

733 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