How can I make this a IIF Statement

Corey

Registered User.
Local time
Today, 01:16
Joined
Sep 14, 2005
Messages
35
Hi again everyone,

I'm stumped again.

I have two tables that my query is looking at.

1. tblProgramActByDay
And the other is:
2. tblProgramByProductByDay

I’m trying to tell the query to
A: Look in the Program ID Field
B: if the Program ID Field = 1667100
C: Go to the table tblProgramByProductByDay

---- In that table look for the criteria---

The Field Program ID must = 0
The Field Product ID must = 38648800
The Field Locale must = en_US
The Field Report_Date must = The Current Month

If it does

Total the amount in the Sales Field from the table tblProgramByProductByDay

If not

Take the total sales for the current month from the table tblProgramActByDay
 
Well, here goes nothing

Select Sum(IIf(Select * from tblProgramActByDay
WHERE ProgramID = 1667100,IIf(Select * from tblProgramByProductByDay
WHERE ProgramID = 0 AND ProductID = 38648800
AND Locale = en_US
AND Report_Date = The Current Month,tblProgramByProductByDay.Sales),tblProgramActByDay.Sales )

Or, perhaps the Sum should be applied inside the IIf statement against each Sales field call.

I have absolutely no idea if this isn't total gibberish; I just thought I'd give it a shot.

by the way, for some reason, there is a space in the last call to the sales field. it shouldn't be there, but doesn't show up in edit mode.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom