Link to home
Start Free TrialLog in
Avatar of John-S Pretorius
John-S PretoriusFlag for United States of America

asked on

Crystal Report to detect a change in field

I have a Crystal report sorting by group and within each group I have a specific field "Type" which is a string.

For normal operations generated by the report this field will always show the same result "TAGM" but from time to time I have a violation which will be reported under "WGDC" for the same field.

I am looking for a way/formula that will indicate within each grouping when there is a change.

Your assistance would be greatly appreciated.


John-S Pretorius.
Avatar of Mike McCracken
Mike McCracken

You could use conditional formatting to highlight the record when the value is NOT TAGM

Right click the TYPE field
Click FORMAT FIELD
Click the BORDER tab
Click the formula button the the right of BACKGROUND
If CurrentFieldValue <> "TAGM" then
    crTeal

mlmcc
Avatar of John-S Pretorius

ASKER

I actually need to be able to create a filtered report at the end, that will only show the violations under each group and not short/show any of the other transactions that have no violations.

I was thinking of using a if statement triggering the change and then sorting only the violations or changes under the same group.

Thank you for your suggestion - any other ideas?
You can use the select expert to filter out and show only the non-TAGM records.
   {TypeField}  <> "TAGM"

mlmcc
I may have not been completely clear about what I'm trying to achieve, I apologize.

Each user has 2 sets of access keys, tagm or wgdc and within a cycle which typically may be entry and exit are only allowed to use one type.

I am looking for just the violations when there is a change of card type usage and don't care about the rest of the valid 'same' type records
So if they start with TAGM you want to see the WGDC records and vice versa.

Add 2 formulas
Name - HasTAGM
If {Type} = 'TAGM' then
    1
else
    0

Name - HasWGDC
If {Type} = 'WGDC' then
    1
else
    0


You could group by user
Use group selection as
Sum({@HasTAGM,{NameField}) > 0
AND
Sum({@HasWGDC,{NameField}) > 0


In the group header add a formula
WhilePrintingRecords;
Global StringVar FirstType;
FirstType := {TypeField};
""

Conditionally suppress the detail section with
WhilePrintingRecords;
Global StringVar FirstType;
FirstType = {TypeField}

mlmcc
Just to confirm if they start the day with wgdc and it changes to the other and vice versa I want the report to group them.

This looks good so far and I will test it shortly.

Thanks for your patience, I will give you feedback in a short while.
I am getting stuck adding a Group header, as I  already had a group sorting each user.

Where do I add the indicated 'Group header' - When I run the report without the last 2 instructions I have a clear page, none of my page header or anything.

Any ideas please.
May I kindly request if you could look at the attatched file please - I'm not sure what I'm missing here. QCS-Monthly-Users-Activity.rpt
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
mlmcc you nailed it - that is really awesome, thank you this is certainly exactly what I was trying to do.

I will award you the points (not that al this about, surely) but I would like to keep it open for a little while longer as I may need to add a scenario where for instance if the first entrance was thru Device #52 (Broadway overhead tag - any one is alowed to start a transaction with this type TAGM and then follow thru with _WGDC as long as it stays at that)

Do you think it would be hard to add something like that ?

Thanks again, I hope we can complete the last request together.
Probably not too tough.

You can close and then we can still continue the discussion if you wish.

mlmcc
You are the best, thank you so much -  I am going to have to follow you :)
I have so much to learn but luckily there's people like mlmcc.
Good day mlmcc, I am looking at adding another 'check' that needs to be allowed as a valid 'violation' : if the device.design = "broadway Overhead Tag" ignore that first read.

I am also looking into functionality on how to trigger a email/print  when such a violation occures. Currently I use easyview to auto generate a report every Hour and just email it out.

Is there a way to run the report and if it finfs a violation do something : email/print ?
With the new report you should only get a report if there are violations.

Is the device.design = "broadway Overhead Tag" ever on a second or later record?

mlmcc
Unless they exit and come back in thru the same entrance. What if we just ignore that device completely ({device.design} = "Broadway overhead Tag" or it also goes by {device.number} = 52)

We are only concerned about this device - ignore it completely.
That was what I was thinking was to add that to the record select as
    {device.number} <> 52

mlmcc
Worked perfectly...."What about triggering ?" or running a stored sql request and then emailing/printing when the violation occurs.
Crystal cannot "trigger" anything.

Are you running this from an application?

mlmcc
Yes I'm using easyview to batch generate a bunch of reports and email them out.
The report is 100% complete now, thanks to you! You should be proud that I was able to get rid of all unwanted "numberlous" IDTag users that did not have anything asigned yet. I also changed the grouping from >0 to >2 which gives me a true violation report that Rocks.

My last Question if I may please : " How can I output at least some text if there is no violations or data to print" - currently it's just a blank page, and I would like to say maybe : "No Violationf for " {report.date} (Date)
You can add a field to the report header or page header that says what you want

You can conditionally suppress it with

Count({SomeField}) > 0

mlmcc
No its not, it just used for a outside building reader which is only used once.
I learnt allot, thank you. when can we do the next challenge I am working on something a little more juicy defiantly worth 500 points
Please help, I'm trying to add the following to the excisting formula :

I am trying to show if a grouped  userIDTag has a duplicate movement (entry) which will show as a 0 in the system - please see image.

I am thinking that :
({ContractParkersMovement.UserIDTag},{ContractParkersMovement.MovementType}) <> 
 next ({ContractParkersMovement.UserIDTag},{ContractParkersMovement.MovementType}

should do this but keep getting a error with the formula. User generated image