Problems with dates and totals

What you should do is delete the data in the table everytime you push the button on the form. This way you wont get repeating entries. I should of put code on there to do that...my bad. Adding these lines to the code will clear out the table:
Code:
Dim strDeleteSql As String
 
strDeleteSql = "DELETE Table2.* FROM Table2;"
CurrentDb.Execute strDeleteSql

Put that at the end of the Dim section.

As for how it's being calculated, here is what is happening:

The code opens up the Query called "Query1". It goes to the first record. It assigns the time from that query to the variable called dtmTime1 .It then tests to see if the variable called dtmTime2 has a value. If the value is "12:00:00 AM" (Which is what happens when there is no value assigned to it) If that is true, It moves Time1 into the Time2 variable, grabs the time from the next record and records it as Time1. Then goes to the next record to start the process over again.

If Time2 has a value other than "12:00:00 AM", It takes the difference, in seconds, between Time2 and Time1. It then opens up Table2, and inserts the txn_ID number and the difference into a new record. It then moves Time2 into Time1. It then repeats the process.

It will continue to repeat the above process until it gets to the end of the file. When it hits that point, the code has done it's job and it exits the subroutine.
 

Users who are viewing this thread

Back
Top Bottom