View Full Version : Creating an invoice report


the bard
11-09-2007, 06:51 AM
I am trying to create an invoice with up to 5 items.Each item is sub-totalled using Total1 = Price1*Quantity1 throught to item 5. I use the formula Totalgoods=Total1 + Total2 etc which works provided there are 5 items, any less and it will not total. I have tried various other ways to total without success. Any ideas?

Robjoy
11-09-2007, 08:47 AM
You need my favourite function: Nz. The problem is probably that the unused items are Null, so Access falls over them rather than doing the human thing of treating them as zero. Change your total to read: Totalgoods = Nz(Total1,0)+Nz(Total2,0) . . .

ajetrumpet
11-09-2007, 08:50 AM
I use the formula Totalgoods=Total1 + Total2 etc which works provided there are 5 items, any less and it will not total. I have tried various other ways to total without success. Any ideas?Bard, here are a couple of methods I have used to total the control values on a form (works the same for reports)...

* Write a Conditional Loop

* Sum all the controls individually writing IIF statements...IIF([control] is null, 0, [control]) + IIF(next control), etc, etc...I have a sample database up too, for an invoicing setup, if you haven't seen it. It might be able to provide some insight as well (though it doesn't do any totaling)...

http://www.access-programmers.co.uk/forums/showthread.php?t=137158

the bard
11-12-2007, 01:31 AM
The function Nz worked perfectly - many thanks.