My question is to find out the time difference between finish time of first record and start time of the next record for the same person as it will give us the exact time measurement how much time the user was free after inserting his first record and before starting a new record. This is elapsed time i am going to calc. I have written the following function to find out the elapsed time. but my problem is now when I insert a record then elapsed time is coming up same as that of start time of that record. But in actual the elapsed time should be:
Difference between finish time of the last saved record of the same person and start time of the new record the person going to insert in the table.
Difference between finish time of the last saved record of the same person and start time of the new record the person going to insert in the table.
Code:
a = Timefunc1(Format(Date, "dd/mm/yyyy"), TextBox10.Value, TextBox8.Value, TextBox11.Value)
With rs
.AddNew
.Fields("Refno") = TextBox9.Value
.Fields("Date1") = Format(Date, "dd/mm/yyyy")
.Fields("Process1") = "Batch"
.Fields("Name") = TextBox10.Value
.Fields("Formfamily") = ComboBox6.Value
.Fields("Batchedby") = ComboBox5.Value
.Fields("Volume") = TextBox2.Value
.Fields("starttime") = TextBox8.Value
.Fields("Finishtime") = TextBox11.Value
.Fields("Elapsedtime") = a
.Update
End With
Code:
Public Function Timefunc1(AnyDate As Date, AnyPerson As String, AnyStartTime As Date, AnyEndTime As Date) As String
Dim dtmLower As Date
Dim dtmUpper As Date
dtmUpper = AnyStartTime
dtmLower = nz(DMax("[Finishtime]", "[tblbatchdetails]", "[Name]='" & AnyPerson & "' And [Date1] = #" & AnyDate & "# And [Finishtime] < #" & AnyStartTime & "#"), 0)
Dim dtmtotaltime As Date
dtmtotaltime = dtmLower - dtmUpper
Timefunc1 = dtmtotaltime
end function