invalid use of null

XaloRichie

Registered User.
Local time
Tomorrow, 00:57
Joined
Jul 2, 2003
Messages
70
I have a line of code :

CIT = DLookup("[SumOfAmountIN]", "TotCBINS")

which looks in a recordset of a query for the total cash entered.
If there is a day without entries (Possible) then the query has no data and I get the error "Invalid use of null"

How do I get round this as there could be days without cash comming into the till?

All suggestions welcome thanks
 
CIT = Nz(DLookup("[SumOfAmountIN]", "TotCBINS"),0)
 
thanks

I have tried to use the Nz(,0) on a field in a form too, although it doesnt seem to work.

you see the cashbook form lists In and Out , in two subforms.

the total field which calculates Sum of fields in each sub form shows #Error, when there is no data in the query for that day.
can I get around this? so if there are no entries the total shows 0
 
Prior to your line of code, do a DCount on the same criteria. If this is zero, you can just force a zero to CIT. If not, then you can do your lookup or whatever.

For that matter, it sounds to me like you should be able to test the counts for your In and Out categories separately to see if either or both of them are zero. Again, DCount is your solution.
 

Users who are viewing this thread

Back
Top Bottom