O
Onno
Hi, I hope you can help me.
I have a 'logging' database with records like this
<Time> <Some Event> <Param1> <Param2> <Param3>, etc.
Different instances of an application wrote 'start' and 'end' events
to the database and used the param fields to indentify themselves (by
IP address and other items), so the table looks something like this:
2008-09-02 11:58:41, App Started, 199.144.248.152,,
2008-09-02 12:58:41, App Started, 199.144.248.155,,
2008-09-02 13:00:00, App Ended, 199.144.248.152,,
2008-09-02 13:01:11, App Ended, 199.144.248.155,,
In VBA, I want to calculate how long the application was executed (so
the sum of the time fields of all the "App Started-App Ended" record
pairs that belong together based on Param1.
What is the best approach?
I was opening the database using a recordset and walking through all
records like the code below, but got stuck. There must be a better
way. Any better ideas using some smart queries?
Orignal approach:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset([query that only shows the App Started and
Ended events)
Do While Not rst.EOF
If rst!ActionType = 1 Then ' App started
' Now what
ElseIf rst!ActionType = 2 Then ' TAF app closed
' must find matching start action, then add the time
diffs to a sum
End If
rst.MoveNext
Loop
btw: I am not a heavy SQL / Access expert
TIA
I have a 'logging' database with records like this
<Time> <Some Event> <Param1> <Param2> <Param3>, etc.
Different instances of an application wrote 'start' and 'end' events
to the database and used the param fields to indentify themselves (by
IP address and other items), so the table looks something like this:
2008-09-02 11:58:41, App Started, 199.144.248.152,,
2008-09-02 12:58:41, App Started, 199.144.248.155,,
2008-09-02 13:00:00, App Ended, 199.144.248.152,,
2008-09-02 13:01:11, App Ended, 199.144.248.155,,
In VBA, I want to calculate how long the application was executed (so
the sum of the time fields of all the "App Started-App Ended" record
pairs that belong together based on Param1.
What is the best approach?
I was opening the database using a recordset and walking through all
records like the code below, but got stuck. There must be a better
way. Any better ideas using some smart queries?
Orignal approach:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset([query that only shows the App Started and
Ended events)
Do While Not rst.EOF
If rst!ActionType = 1 Then ' App started
' Now what
ElseIf rst!ActionType = 2 Then ' TAF app closed
' must find matching start action, then add the time
diffs to a sum
End If
rst.MoveNext
Loop
btw: I am not a heavy SQL / Access expert
TIA