Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help Please - report for access control system Post Reply Post New Topic
Author Message
Stoney
Newbie
Newbie


Joined: 07 Jul 2009
Online Status: Offline
Posts: 2
Quote Stoney Replybullet Topic: Help Please - report for access control system
     Posted: 07 Jul 2009 at 2:57pm
Hi im trying to write a report for an access control database that shows me when people are still in the building.
 
Please go easy with me in new to Cyrstal reports.
 
In my table i have.
 
Date                                 CardNumber      DoorName      EventType
07/07/2009 09:00:00              1                 Front Door           in
07/07/2009 09:01:00              2                 Front Door           in
07/07/2009 09:02:00              3                 Front Door           in
07/07/2009 10:00:00              2                 Front Door           out
07/07/2009 10:10:00              4                 Front Door           in
07/07/2009 11:00:00              1                 Front Door           out
 
So the data i want is
 
Date                                 CardNumber      DoorName      EventType
07/07/2009 09:02:00              3                 Front Door           in
07/07/2009 10:10:00              4                 Front Door           in
 
 
Thanks for the help in advance :)
 
John
 
 
 


Edited by Stoney - 07 Jul 2009 at 11:51pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Jul 2009 at 6:15am
I would suggest using a stored procedure.  they are much more flexible than Crystal when it comes to data manipulation.
 
It appears that what you want all cards that have an odd number of entries.  So I would start there. Simplest, group by card number, suppress the group and details if the COUNT({table.cardnumber}, cardNumberGroup) mod 2 =0
 
This will leave all the records that have an odd number, then in the group footer, display the last record (just suppress the detail and order by date)
 
Hopefully this works...it should, or at least get you close.
 
HTH
IP IP Logged
Stoney
Newbie
Newbie


Joined: 07 Jul 2009
Online Status: Offline
Posts: 2
Quote Stoney Replybullet Posted: 08 Jul 2009 at 9:42am
I was just trying out your solution but i realised that the user can swipe in/out more than once.
 
Also what do you mean by "stored procedure"? ive not been doing reports etc long.
 
Thanks
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Jul 2009 at 10:00am
Stored procedures are batch files (so to speak) of SQL commands that you can run.  Crystal can use them as a datasource just as easily as the tables that you are using.
 
The solution outlined actually takes into account the multiple swiping.  The suppression of sections by mod 2 = 0 is if there are multiples of 2 for swipes ignore them...1 in, 1 out. If the swipes are grouped by date, this should work, unless you have people who regularly are there past midnight.
 
simple way to see this in action.  Start you report as you regularly do (with all the swipes). Create a group by user, and one by date. Create a formula like:
count(({table.userid}, dateGroup) mod 2 = 0
 
put the formula on the detail line and display the results.  What you should see is all swipes ending with an out are true, all the rest are true.
in the date group footer put the info that you want to see ( which should be the swipe in).  preview the report  again, and you should see the last record of each group in the group footer.  If everything is looking good, suppress the group headers and detail lines and the group footer for the userid.
 
Now your report is just the last line for every person for every day.  Copy your formula into the Section Expert/Suppress formula (x-1) button) for the date footer. Click ok to get back to the preview, and you should see just the footer line for the people who have not swiped out on the same day that they swiped in.
 
You can add refinements for people past midnight, but this should get you started.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum