Solved

Excluding data from one table field looking up that value from another

Posted on 2016-08-20
6
68 Views
Last Modified: 2016-08-23
Using Crystal Reports IX with SQL Server 2014

 I need to exclude a value based on the value stored in a table field where I lookup the value in another table.  Since this report would be run by multiple agencies and they use their own user assigned value for a "House Watch" I need to find that value from the param3 field in the table ListUCR.


Table and Field I will be excluding data on:    
Table Name: CaseMaster
Table Field: UCRCodeAll   (Varchar)

7725,7741
7725
7314,7725
7314,7741,7725

Table and Fields I am looking up to obtain the value in  the Code field based on a string value in a param3 field.

Table Name: ListUCR
Table Fields: Code        (Char)
Table Field Param3      (Varchar)

Example Department 1

Code            Description                     Param3
7225            HOUSE WATCH               HOUSE WATCH     (Query would use 7225)

Example Department 2

Code            Description                     Param3
7845           HOUSE WATCH               HOUSE WATCH     (Query would use 7845)


I can get it to work if I hardcode a particular value into the query:
not ({CaseMaster.UCRCodeAll} like "*7225*")

But when I try the below listed query it fails to return any records.
{CaseMaster.UCRCodeAll} <> {ListUCR.Code} and ({ListUCR.Param3} Like 'HOUSE WATCH')


Mike
0
Comment
Question by:MikeM670
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 41763993
What is the full query? or at least the full FROM and WHERE clauses?

mlmcc
0
 

Author Comment

by:MikeM670
ID: 41764003
{ClosedCallControl.EnrouteBadge} like ["*" + {?Officer}] and
{ClosedCallControl.InitiationTime} >= {?Start Date} and
{ClosedCallControl.InitiationTime} <= {?End Date} and
{ClosedCallControl.Agency} = {?Agency} and
{CaseMaster.UCRCodeAll} <> {ListUCR.Code} and ({ListUCR.Param3} Like 'HOUSE WATCH')
//not ({CaseMaster.UCRCodeAll} like "*7225*")    (This works)
//{CaseMaster.UCRCode1} like {ListUCR.Code} where ({ListUCR.Param3} Like 'HOUSE WATCH')  (This did not)
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 41764617
<> is not the same as NOT LIKE

Should this
{CaseMaster.UCRCodeAll} <> {ListUCR.Code} and ({ListUCR.Param3} Like 'HOUSE WATCH')

be
({CaseMaster.UCRCodeAll} <> "*" & {ListUCR.Code} & "*") and ({ListUCR.Param3} Like 'HOUSE WATCH')

mlmcc
0
Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

 

Author Comment

by:MikeM670
ID: 41766295
mlcc,

Thanks for getting back to me.  

I tried the corrected query you provided and it only returns House Watches.  Which is funny because that is what I wish to exclude from the query and return all other UCRCodes.

If I specifically hardcode a UCR Code value into the query it works fine but when I try to check the ListUCR Table for the Param3 value of "House Watch" it returns only house watches.


Mike
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 500 total points
ID: 41766920
If you don't want "house watch" then use NOT

({CaseMaster.UCRCodeAll} <> "*" & {ListUCR.Code} & "*") and (NOT(({ListUCR.Param3} Like 'HOUSE WATCH')))

mlmcc
0
 

Author Closing Comment

by:MikeM670
ID: 41767435
That did it!  I had tried using not before but not against the Param3 value specifically.  

Thank you very much for the assistance!
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question