?
Solved

Tracking Logins In CR 8

Posted on 2001-07-06
13
Medium Priority
?
265 Views
Last Modified: 2012-05-04
I have a table that tracks the logins of users to a website.  They login and the table captures there:
[UserID], [Logindate] (Userid is numeric & the Logindate field has both date and time in it).

For a project I need to count how many times a person logged in for a date range, Usually a monthly range, however there is a catch, if the person logs in again and its less than 60 minutes since the last time they logged in, it should only count as 1 login.

I figure I could group by [Userid] and sort the [Logindate] field in Ascending order and create a Formula field that has a "If Then Else" that looks at the current [Logindate]field in the record and compares it to the [Logindate] field in the previous record and if its less than 60 minutes make the Formula field = 0 and if not it = 1, then do a Sum on this field and I should have my problem solved!  However how do I compare against a previous record? Is there a function for this?

P.S. I am using Crystal reports 8 But I also have access to CR 8.5 if needed!
0
Comment
Question by:ewalsh
[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
  • 7
  • 5
13 Comments
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6260170
EWalsh

Use the PreviousValue({fieldname}) function.  Example to follow in a second.
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6260209
Sorry, gave you wrong syntax

Try something like this

dateTimeVar OldDate := Previous({logins.logindate});
dateTimeVar CurDate := {logins.loginddate};
stringVar OldLogin := Previous({logins.userid});
stringvar CurLogin := {logins.userid};

if OnFirstRecord or PreviousIsNull({logins.userid}) then
1
else
if OldLogin <> CurLogin then
  1
else
if datediff("n", OldDate, CurDate) > 60 then
1
else
0
0
 

Author Comment

by:ewalsh
ID: 6267150
Ok, It looks like this works, But know there is a new problem, I cant SUM up on this formula field!
It doesnt list it as a filed in the "Insert Summary"
Or if I try to make a Running Total Field!
I made another formula field that simply showed 1 if it = a specific company name else 0.  And that Formula field WOULD allow me to create a summary or a running total field.
But then I CUt/Copied the original into this test field and then I couldn't use it again!  VERY ODD!!!
I tell you as powerful as CR is I sometimes hate it,  MS Access is so much easier when it comes to this stuff!

P.S.  I tried this on 2 diff machines one running CR 8  the other running CR 8.5
0
Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

 

Author Comment

by:ewalsh
ID: 6267156
It seems that if I omit any refrence to Previous()  it will allow to SUM up, But enter a Previous() Function and NO DICE!!!
0
 

Author Comment

by:ewalsh
ID: 6267175
I am using Crystal Syntex
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6267177
ewalsh

This would be fairly trivial if you could use VB as a front end to the Crystal Report.  Is that a possibility?
0
 

Author Comment

by:ewalsh
ID: 6267553
I'm afraid not.  However, in VBA is there a Previous() Function equivalnt?  If so I'd do it in MS Access.
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6267685
You don't need a previous function.  Build a temp table in Access by using a recordset object to step through your logins table in loginid/date order.  As you step through the original table, compare the login/date time to the previous one that you'll keep in a variable.  A psuedo process to do this...

dim oLogindate as datetime
dim oLoginID as long
Open recordset for original file
Open empty recordset for temp file
oLoginDate = #01/01/1980#
oLoginID = originalrecordset!loginid
while not at end of recordset
  if datediff('n',oLoginDate, recordset!logindate) > 60 OR oLoginID <> originalrecordset!loginid then
  temprecordset.addnew
  temprecordset!loginid = orginalrecordset!loginid
  temprecordset!logindate = originalrecordset!logindate
  temprecordset.update
  end if
  oLoginDate = originalrecordset!logindate
  oLoginID = originalrecordset!loginID
  originalrecordset.movenext
loop

This should give you a table in your temp table that contains only one record for any given user within any 60 minute period.  Base your report off the temp table.

Sorry about the sloppy code - I don't have Access at home - but this will get you going.
0
 

Author Comment

by:ewalsh
ID: 6277893
Well looks like this is a problem within CR (all version up to 8.5)  Wrote to CR's tech support and this was there reply.
------------------------------

To resolve your issue you should change your IF statement.

Whileprintingrecords;
Numbervar Counter;
not onfirstrecord;
if datediff ("n", previous
({LOGINRECORD.LOGINDATE}),{LOGINRECORD.LOGINDATE}) > 60 then
Counter := Counter + 1


This will give you a count for you. However this is not the only formula you will need.
You will need a reset formula for the variable "Counter" in the Group Header that you would like it to reset in. One more to display it. This is referred to as a Manual Running Total and this will be your only option
due to the point of evaluation when using the previous function.

For further information on Manual Running Totals, you can search:
http://support.crystaldecisions.com   for Everything You Need to know
about running Totals. Or http://support.crystaldecisions.com/library/ 
search: scr_running_total.zip


Kind regards,
Chad
Tech 909
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6301030
EWalsh

Been away for awhile.  If you want to close the question without awarding points, leave a message in community support asking them to PAQ this question.

DRRYAN3
0
 
LVL 12

Expert Comment

by:DRRYAN3
ID: 6318142
EWalsh

If you want to close the question without awarding points, leave a message in community support asking them to PAQ this question.

DRRYAN3
0
 
LVL 12

Accepted Solution

by:
DRRYAN3 earned 1200 total points
ID: 6376393
Since I answered your original question, and you state "looks like this works, but there is a new problem" I am locking this question as I feel I answered it.  You should have opened a new question.

DRRYAN3
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6402497
Force Accepted by:
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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