A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

2 condition



 
 
Thread Tools Display Modes
  #1  
Old July 30th, 2009, 02:25 AM posted to microsoft.public.access.reports
mavis
external usenet poster
 
Posts: 85
Default 2 condition

Hi All,

I have the below code. what i need is to pull out all record exclude those
which ClaimStatus does not equal to "Closed" or "Paid" and ClaimedAmount is
not null. When i run the below code, record with "Paid" and 'Closed" Status
still show.

Please kindly advice. Thanks in advance.

SELECT TBLCargoClaims.Vessel, TBLCargoClaims.Voyage, TBLCargoClaims.ID,
TBLValueClaim.ClaimedAmount, TBLValueClaim.ClaimCurrency,
TBLValueClaim.ValuableROE,
[TBLP&IVoyAccurmulativeRecovery].DeductibleApplied, TBLCargoClaims.ClaimStatus
FROM (((TBLCargoClaims LEFT JOIN TBLValueClaim ON
(TBLCargoClaims.BillofLading=TBLValueClaim.BillOfL ading) AND
(TBLCargoClaims.ID=TBLValueClaim.ClaimNumber)) LEFT JOIN
[TBLP&IVoyAccurmulativeRecovery] ON
(TBLCargoClaims.Voyage=[TBLP&IVoyAccurmulativeRecovery].Voyage) AND
(TBLCargoClaims.Vessel=[TBLP&IVoyAccurmulativeRecovery].Vessel)) LEFT JOIN
[TBLP&IRecov] ON TBLCargoClaims.ID=[TBLP&IRecov].ClaimID) INNER JOIN
TBLRecovery3rdParty ON TBLCargoClaims.ID=TBLRecovery3rdParty.ClaimNumber
WHERE (((TBLValueClaim.ClaimedAmount) Is Not Null) AND
((TBLCargoClaims.ClaimStatus)"Closed")) OR (((TBLValueClaim.ClaimedAmount)
Is Not Null) AND ((TBLCargoClaims.ClaimStatus)"Paid"));
  #2  
Old July 30th, 2009, 03:44 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default 2 condition

Try changing the WHERE clause like this:
WHERE (TBLValueClaim.ClaimedAmount Is Not Null)
AND (TBLCargoClaims.ClaimStatus NOT IN ("Closed", "Paid"));

The way it was, records where ClaimStatus is "Closed" still meet the
criterion that ClaimStatus not "Paid" and so they get included when you use
OR (i.e. meet either criterion.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"mavis" wrote in message
...
Hi All,

I have the below code. what i need is to pull out all record exclude those
which ClaimStatus does not equal to "Closed" or "Paid" and ClaimedAmount
is
not null. When i run the below code, record with "Paid" and 'Closed"
Status
still show.

Please kindly advice. Thanks in advance.

SELECT TBLCargoClaims.Vessel, TBLCargoClaims.Voyage, TBLCargoClaims.ID,
TBLValueClaim.ClaimedAmount, TBLValueClaim.ClaimCurrency,
TBLValueClaim.ValuableROE,
[TBLP&IVoyAccurmulativeRecovery].DeductibleApplied,
TBLCargoClaims.ClaimStatus
FROM (((TBLCargoClaims LEFT JOIN TBLValueClaim ON
(TBLCargoClaims.BillofLading=TBLValueClaim.BillOfL ading) AND
(TBLCargoClaims.ID=TBLValueClaim.ClaimNumber)) LEFT JOIN
[TBLP&IVoyAccurmulativeRecovery] ON
(TBLCargoClaims.Voyage=[TBLP&IVoyAccurmulativeRecovery].Voyage) AND
(TBLCargoClaims.Vessel=[TBLP&IVoyAccurmulativeRecovery].Vessel)) LEFT JOIN
[TBLP&IRecov] ON TBLCargoClaims.ID=[TBLP&IRecov].ClaimID) INNER JOIN
TBLRecovery3rdParty ON TBLCargoClaims.ID=TBLRecovery3rdParty.ClaimNumber
WHERE (((TBLValueClaim.ClaimedAmount) Is Not Null) AND
((TBLCargoClaims.ClaimStatus)"Closed")) OR
(((TBLValueClaim.ClaimedAmount)
Is Not Null) AND ((TBLCargoClaims.ClaimStatus)"Paid"));


  #3  
Old July 30th, 2009, 03:55 AM posted to microsoft.public.access.reports
mavis
external usenet poster
 
Posts: 85
Default 2 condition

HiAllen,

Thanks! It works great.


"Allen Browne" wrote:

Try changing the WHERE clause like this:
WHERE (TBLValueClaim.ClaimedAmount Is Not Null)
AND (TBLCargoClaims.ClaimStatus NOT IN ("Closed", "Paid"));

The way it was, records where ClaimStatus is "Closed" still meet the
criterion that ClaimStatus not "Paid" and so they get included when you use
OR (i.e. meet either criterion.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"mavis" wrote in message
...
Hi All,

I have the below code. what i need is to pull out all record exclude those
which ClaimStatus does not equal to "Closed" or "Paid" and ClaimedAmount
is
not null. When i run the below code, record with "Paid" and 'Closed"
Status
still show.

Please kindly advice. Thanks in advance.

SELECT TBLCargoClaims.Vessel, TBLCargoClaims.Voyage, TBLCargoClaims.ID,
TBLValueClaim.ClaimedAmount, TBLValueClaim.ClaimCurrency,
TBLValueClaim.ValuableROE,
[TBLP&IVoyAccurmulativeRecovery].DeductibleApplied,
TBLCargoClaims.ClaimStatus
FROM (((TBLCargoClaims LEFT JOIN TBLValueClaim ON
(TBLCargoClaims.BillofLading=TBLValueClaim.BillOfL ading) AND
(TBLCargoClaims.ID=TBLValueClaim.ClaimNumber)) LEFT JOIN
[TBLP&IVoyAccurmulativeRecovery] ON
(TBLCargoClaims.Voyage=[TBLP&IVoyAccurmulativeRecovery].Voyage) AND
(TBLCargoClaims.Vessel=[TBLP&IVoyAccurmulativeRecovery].Vessel)) LEFT JOIN
[TBLP&IRecov] ON TBLCargoClaims.ID=[TBLP&IRecov].ClaimID) INNER JOIN
TBLRecovery3rdParty ON TBLCargoClaims.ID=TBLRecovery3rdParty.ClaimNumber
WHERE (((TBLValueClaim.ClaimedAmount) Is Not Null) AND
((TBLCargoClaims.ClaimStatus)"Closed")) OR
(((TBLValueClaim.ClaimedAmount)
Is Not Null) AND ((TBLCargoClaims.ClaimStatus)"Paid"));



 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.