|
-
May 29th, 2003, 11:09 AM
#1
Thread Starter
Fanatic Member
Why does this not work? **Resolved**
On the footer of a from set to "Continuous Forms" I have a text box with this code in it.
=IIf(IsNull(Sum([FinalPrice])),0,Sum([FinalPrice]))
FinalPrice is the name of a text box that contains another calculation. Why should this not work this time?
Last time I did this the form was backed by a table and was filtered. this time it's backed by a query. surely that's not the reason!?
the output is: #Error
Last edited by Matt_T_hat; Jul 31st, 2003 at 06:04 AM.
-
May 29th, 2003, 11:31 AM
#2
This is an Access report? Your syntax is correct, but the
issue may be from the text box not yet being displayed so it is
neither null or 0. So by the IIF statement it will go to the false
scenerio. Then when it tries to display the contents there is
nothing to display so the formula get the #ERROR. You can not do
a SUM on all the instances of a text box. Can you use the field
from the query instead?
Can you post more information so we can be able to guide you in
the right direction?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 29th, 2003, 02:14 PM
#3
Hyperactive Member
Another possibility is this: If the [Final Price] does not contain a value in every record then the result will be #Error as Access cannot Sum a null. I would suggest that you add a further condition to your query controlsource for [Final Price]. Something along the lines of iif(isnull([Final Value],0,[Final Value]) so you don't have any empty fields being summed.
Just a thought.
-
May 29th, 2003, 05:28 PM
#4
Thread Starter
Fanatic Member
[Final value] is a calculated result and at present with some junk data in the DB no blank fields result.
From expirence nothing to add up results in nul returned and no maths is done.
Something along the lines of iif(isnull([Final Value],0,[Final Value]) so you don't have any empty fields being summed.
is a stunning idea but doesn't help much at the mo.
Still work is over for the day.
-
May 30th, 2003, 11:00 AM
#5
Thread Starter
Fanatic Member
IT's an access 2000 database
The control source is now set to =sum([finalprice]) and still nothing.
It errors whatever I do.
For a time a second textbox set as defult = sum([finalprice]) gave the first row as an answer but that sits there blank.
I can find no deviation from when I've done it before.
FinalPrice is achieved via =([Unit Price]*[AmmountReq]) as the control
and the whole is backed by a query that has SQL:
Code:
SELECT Job.[Job ID], Example.Discriptor, Example.Size, Feature.Name, Feature.Measure, Material_Required.Qantity, _
[GET Cheapest Supplier].Qty, [GET Cheapest Supplier].Unit.Name, [GET Cheapest Supplier].[Unit Price], [GET Cheapest Supplier].[Unit ID], _
[GET Cheapest Supplier].Supplier.Name
FROM (Feature LEFT JOIN ([GET Cheapest Supplier] RIGHT JOIN Material_Required ON [GET Cheapest Supplier].[Unit ID] = _
Material_Required.[Unit ID]) ON Feature.[Feature ID] = Material_Required.[Feature ID]) RIGHT JOIN (Job LEFT JOIN Example ON Job.[Job ID] = Example.[Job ID]) _
ON Feature.[Feature ID] = Example.[Feature ID]
WHERE (((Example.Disable)<>True))
WITH OWNERACCESS OPTION;
could my query be in the way somehow? I thought you could pritty much treat them like tables.
Last edited by Matt_T_hat; May 30th, 2003 at 11:09 AM.
-
Jun 3rd, 2003, 05:03 PM
#6
Lively Member
3 Things
1. Your line: =IIf(IsNull(Sum([FinalPrice])),0,Sum([FinalPrice])) is a tad heavy on the functions
Wouldn't =Nz(Sum([FinalPrice])) do the same thing?
2. The SQLhas a possible spelling mistake - you refer to a field called Qantity, and not Quantity. This may however just be a typo.
3. If the worst comes to the worst with your Sum function then consider using the DSum() domain aggregate function.
-
Jul 31st, 2003, 06:01 AM
#7
Thread Starter
Fanatic Member
Sorry that was a bit rude of me, thanx for the help I don't remember how exactly but the customer is a happy one now.
BTW: Qantity was a badly named fieldname... lol
-
Jul 31st, 2003, 09:41 AM
#8
Originally posted by MileOut
1. Your line: =IIf(IsNull(Sum([FinalPrice])),0,Sum([FinalPrice])) is a tad heavy on the functions
Wouldn't =Nz(Sum([FinalPrice])) do the same thing?
This is not the same. From Ephesians's post will show the reason.
If the SUM([FinalPrice]) is equal to Null then the Access report will
show #Error on the report.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 4th, 2003, 04:01 AM
#9
Thread Starter
Fanatic Member
Originally posted by RobDog888
This is not the same. From Ephesians's post will show the reason.
If the SUM([FinalPrice]) is equal to Null then the Access report will
show #Error on the report.
I see. Thankyou I was not fully aware of this.
-
Aug 5th, 2003, 07:19 AM
#10
Hyperactive Member
SUM(Nz([FinalPrice], 0)) should work tho.
-
Aug 5th, 2003, 07:43 AM
#11
Thread Starter
Fanatic Member
Originally posted by Granty
SUM(Nz([FinalPrice], 0)) should work tho.
Good Use of default values and data integrity checks in the first place would be the best route.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|