Solved

DSum cancelling on Error 94, Invalid use of Nulls

Posted on 2011-02-17
3
813 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

786 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