I have an Access Database to store my software license usage data and provide reports. The license manager is proprietary and has no reporting features whatsoever.
I import the data from the vendor log file:
User UserGroup UniqueIdentifierCookie Action Module DateTimeStamp
userid region text string of numbers CheckOut or CheckIn ModuleUsed [obvious]
The software assigns a unique identifier (called a cookie, not really a cookie as we know it from web browsers) when the user opens a module and takes a license. This is recorded with which module is used, and of course a date/time stamp. When the user checks in that license, the cookie is repeated with CheckIn as the action and another date/time stamp. So each step gets a separate line in the code.
I load the table as a recordset, and if the action is "checkout" then i read the cookie.
Here's where i get lost. I need to find the corresponding row in this same query where the cookie is the same, and read the timestamp from that row. Only right now, there are over 41,000 entries in this table and i don't want to have to cycle through 40,000 rows looking for whether the cookie matches. The table is only going to grow. The CheckIn data is typically well within 100 rows of the CheckOut data.
Once i read the checkin timestamp, i can manage the delta time.
but here's tricky part #2. i want to put the resultant delta time value in the row with the CheckIn, not the CheckOut.
How do I determine the row number of the CheckIn Data so i can put the delta time there?
I can accomplish this in Excel, but the file is HUGE and takes forever to load, filter, sort, save, etc (and i have calculation on Manual). Access is a much better place to do this, but i can't figure out this action.
I have searched this forum and found code that will loop me through the entire table, row by row, but I get stuck at the "find record" entry. From what I'm reading, FindRecord might not be what i need to use here.
Code:
Public Sub CalculateDelta()
Dim sSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim td As DAO.TableDef
Dim f As DAO.Field
On Error Resume Next
Set rst = CurrentDb.OpenRecordset("SELECT Cookie, Action, FinalDateTime, Delta FROM [Users Log Query02] ")
' From Users Log Query02, get Cookie, Action, FinalDateTime.
' This is already sorted by Module.
If Not (rst.EOF And rst.BOF) Then
rst.MoveFirst
Do Until rst.EOF = True
TDelta = rst!Delta
If TDelta Is Nothing Then
' Only need to run if there is no delta value already
strAction = rst!Action
If strAction = "CHECKOUT" Then
' Store Cookie as string
strCookie = rst!Cookie
'DoCmd.FindNext where Cookie = CookieString and Action = CHECKIN.???
' Get FinalDateTime of this record.
' DeltaTime = FinalDate2 - FinalDate1
' Place DeltaTime into blank Delta CHECKIN column.
'Move to the next record.
rst.MoveNext
Loop
Else
MsgBox "There are no records in the recordset."
End If
rst.Close
End Sub
Can someone suggest what direction I should try?
Thanks...
Susan