PacketRat
01-13-2002, 09:28 AM
On several different occasions I have come across instances where I must total costs from either multiple forms (as subforms) or directly from queries. What is the best (and easiest) way to do this? The primary problem I run into is that if there is no value for one of my possible summed variables, it causes the result to say '#Error'
[This message has been edited by PacketRat (edited 01-13-2002).]
Fornatian
01-13-2002, 11:25 AM
If you are summing from different tables but with similar conditions you might consider a union query with criteria to pull the relevant records and a second query to sum the info.
Alternatively if it is not aggregate date you are after then you may want to consider using the NZ() function to convert your null(empty) entries to zeros so the #error doesn't appear.
Ian
PacketRat
01-13-2002, 12:12 PM
Okay, what is the NZ() function and where can I use it?
Fornatian
01-13-2002, 12:24 PM
I won't do all the work for you as we all have to read up sometimes but basically Nz() function converts nulls to whatever you specify suchas:
3 + Me!MyTextBox
may cause an error if MyTextBox is null whereas:
3 + Nz(MyTextBox,0)
will not because it will convert the null to zero(Null to Zero
To read up on it do a help search on Nz or press F1 when it has the cursor on it if you're using the code window.
Ian