Less Than IIF Query

AccidentalFate

Registered User.
Local time
Yesterday, 19:42
Joined
Apr 28, 2008
Messages
42
trying to run a query to generate previous CO Sum values. Wrote the query below to do this and it doesn't work... please check it out and let me know what I did wrong.

SELECT Sum(IIf([forms]![Main sub co Fm].[combo27]=1,0,[value $])) AS [Previous CO]
FROM [Sub CO All Q]
WHERE ((([Sub CO All Q].[CO Number])=IIf([forms]![Main sub co Fm].[combo27]=1,1,([Sub CO All Q].[CO Number])<[forms]![Main sub co Fm].[combo27])) AND (([Sub CO All Q].Subcontractor)=[forms]![Main sub co Fm].[combo6]));
 
got the above 1 co to work but still don't know about getting the #1 co to work

make 2 queries

Sub CO Select Sub2Q
SELECT [Sub CO All Q].[Value $], [Sub CO All Q].[CO Number], [Sub CO All Q].Subcontractor
FROM [Sub CO All Q]
WHERE ((([Sub CO All Q].Subcontractor)=[forms]![Main sub co Fm].[combo6]));

Sub CO Select SubQ
SELECT Sum(IIf([forms]![Main sub co Fm].[combo27]=1,0,[value $])) AS [Previous CO]
FROM [Sub CO Select sub2Q]
WHERE ((([Sub CO Select sub2Q].[CO Number])<>[forms]![Main sub co Fm].[combo27]));
 

Users who are viewing this thread

Back
Top Bottom