PC Review


Reply
Thread Tools Rate Thread

in access, if then statement

 
 
dtretina
Guest
Posts: n/a
 
      7th Jun 2010
if (Escalation/Assignment = 0) or (Updateheat = 0 )or (Worklog = 0), then 0
for the total. Else total.

How would you set this up in design query? Each of the above is a seperate
table

Query:
SELECT DISTINCTROW tblMonitoringData_OLD.[HEAT ID],
[tblEscalation/Assignment]![Points Earned]+tblUpdateHeat![Points
Earned]+tblWorklog![Points Earned] AS [Documenation Pts],
[tblEscalation/Assignment].[Points Earned] AS [Escalation?Assign],
tblUpdateHeat.[Points Earned] AS UpdateHeat, tblWorklog.[Points Earned] AS
Worklog
FROM ((tblMonitoringData_OLD LEFT JOIN [tblEscalation/Assignment] ON
tblMonitoringData_OLD.[Escalation/Assignment] =
[tblEscalation/Assignment].ID) LEFT JOIN tblUpdateHeat ON
tblMonitoringData_OLD.UpdateHeat = tblUpdateHeat.ID) LEFT JOIN tblWorklog ON
tblMonitoringData_OLD.Worklog = tblWorklog.ID
GROUP BY tblMonitoringData_OLD.[HEAT ID], [tblEscalation/Assignment].[Points
Earned], tblUpdateHeat.[Points Earned], tblWorklog.[Points Earned];

 
Reply With Quote
 
 
 
 
John Spencer
Guest
Posts: n/a
 
      7th Jun 2010
Do you mean each is a separate field in a separate table?

IIF(tblUpdateHeat.[Points Earned]=0 OR tblWorklog.[Points Earned] OR
[tblEscalation/Assignment]![Points Earned] = 0, 0,
[tblEscalation/Assignment]![Points Earned]+tblUpdateHeat![Points
Earned]+tblWorklog![Points Earned])


Basically the IIF consists of three arguments.
First a conditional statement X=Y
Second the response if the conditional statement is TRUE
Third the response if the conditional statement is NOT TRUE

SELECT DISTINCT tblMonitoringData_OLD.[HEAT ID],
IIF(tblUpdateHeat.[Points Earned]=0 OR tblWorklog.[Points Earned] OR
[tblEscalation/Assignment]![Points Earned] = 0, 0,
[tblEscalation/Assignment]![Points Earned]+tblUpdateHeat![Points
Earned]+tblWorklog![Points Earned]) AS [Documenation Pts]
, [tblEscalation/Assignment].[Points Earned] AS [Escalation?Assign]
, tblUpdateHeat.[Points Earned] AS UpdateHeat
, tblWorklog.[Points Earned] AS Worklog
FROM ((tblMonitoringData_OLD LEFT JOIN [tblEscalation/Assignment] ON
tblMonitoringData_OLD.[Escalation/Assignment] =
[tblEscalation/Assignment].ID)
LEFT JOIN tblUpdateHeat ON
tblMonitoringData_OLD.UpdateHeat = tblUpdateHeat.ID)
LEFT JOIN tblWorklog ON
tblMonitoringData_OLD.Worklog = tblWorklog.ID

Note that I have dropped the group by and changed DistinctRow to Distinct

dtretina wrote:
> if (Escalation/Assignment = 0) or (Updateheat = 0 )or (Worklog = 0), then 0
> for the total. Else total.
>
> How would you set this up in design query? Each of the above is a seperate
> table
>
> Query:
> SELECT DISTINCTROW tblMonitoringData_OLD.[HEAT ID],
> [tblEscalation/Assignment]![Points Earned]+tblUpdateHeat![Points
> Earned]+tblWorklog![Points Earned] AS [Documenation Pts],
> [tblEscalation/Assignment].[Points Earned] AS [Escalation?Assign],
> tblUpdateHeat.[Points Earned] AS UpdateHeat, tblWorklog.[Points Earned] AS
> Worklog
> FROM ((tblMonitoringData_OLD LEFT JOIN [tblEscalation/Assignment] ON
> tblMonitoringData_OLD.[Escalation/Assignment] =
> [tblEscalation/Assignment].ID) LEFT JOIN tblUpdateHeat ON
> tblMonitoringData_OLD.UpdateHeat = tblUpdateHeat.ID) LEFT JOIN tblWorklog ON
> tblMonitoringData_OLD.Worklog = tblWorklog.ID
> GROUP BY tblMonitoringData_OLD.[HEAT ID], [tblEscalation/Assignment].[Points
> Earned], tblUpdateHeat.[Points Earned], tblWorklog.[Points Earned];
>


--

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
Reply With Quote
 
KARL DEWEY
Guest
Posts: n/a
 
      7th Jun 2010
You have the same names as calculated fields and fields that you are joining
tables on.
Which do you want to use in the IIF stateement?

--
Build a little, test a little.


"dtretina" wrote:

> if (Escalation/Assignment = 0) or (Updateheat = 0 )or (Worklog = 0), then 0
> for the total. Else total.
>
> How would you set this up in design query? Each of the above is a seperate
> table
>
> Query:
> SELECT DISTINCTROW tblMonitoringData_OLD.[HEAT ID],
> [tblEscalation/Assignment]![Points Earned]+tblUpdateHeat![Points
> Earned]+tblWorklog![Points Earned] AS [Documenation Pts],
> [tblEscalation/Assignment].[Points Earned] AS [Escalation?Assign],
> tblUpdateHeat.[Points Earned] AS UpdateHeat, tblWorklog.[Points Earned] AS
> Worklog
> FROM ((tblMonitoringData_OLD LEFT JOIN [tblEscalation/Assignment] ON
> tblMonitoringData_OLD.[Escalation/Assignment] =
> [tblEscalation/Assignment].ID) LEFT JOIN tblUpdateHeat ON
> tblMonitoringData_OLD.UpdateHeat = tblUpdateHeat.ID) LEFT JOIN tblWorklog ON
> tblMonitoringData_OLD.Worklog = tblWorklog.ID
> GROUP BY tblMonitoringData_OLD.[HEAT ID], [tblEscalation/Assignment].[Points
> Earned], tblUpdateHeat.[Points Earned], tblWorklog.[Points Earned];
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting an Excel IF statement to an Access IFF statement =?Utf-8?B?cGFya3NqcDE=?= Microsoft Access 4 22nd Apr 2011 07:55 PM
How to use an IF Statement in Access =?Utf-8?B?Wg==?= Microsoft Access 2 28th Jul 2006 08:46 AM
How to use an IF Statement in Access =?Utf-8?B?Wg==?= Microsoft Access 1 27th Jul 2006 07:38 AM
How do I use a SQL statement in an MS Access data access page (HT. =?Utf-8?B?RG9uIE1pY2hhZWxz?= Microsoft Access 0 18th Jul 2006 09:30 PM
iif statement with And statement in query (ms access 2000) =?Utf-8?B?Sk0gS2VsbHk=?= Microsoft Access 1 14th Apr 2005 06:28 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:38 PM.