I have a database that has been created for the purposes of file indexing. What this means for me is, an employee scans images and they will input various details (e.g. Their Name, Client/Requestor, Date Scanned, File Bar-code, Number of Images, Comments, etc) into the database form. This database will not only serve as a means to simply record employee statistics, but as a medium to track user efficiency, productivity and observe trends over time. This will help build a consensus for reports, figures and client quotes.
To achieve this, I needed to also find a way to track times too. So I went ahead and created timers. The employee's times were recorded using a start and end time.
So how I've gone about doing this is, I've created command buttons for Start, Pause/Unpause and End time.
I have two types of times being tracked:
1. The total time (the total elapsed time from when a user clicks on the Start button and stops the timer by clicking the End button)
2. The actual time (same concept but doesn't record time when the Pause button is clicked; which will be my file processing time)
I have 5 text fields that are running times:
txtSessionStart (the code I've written gives me the Short Date and 24-hr time AM/PM for Start and End time, by clicking the respective Start and End command buttons)
txtActualSeconds
txtActualMinutes
txtTotalSeconds
txtTotalMinutes
I've pretty much got everything working in my VBA code. All command functions work as I intended them to. But I've run into one issue. And it's a pretty big one.
The timer data isn't logging back into the row field pertinent to the current record that the user created. Instead what happens is, a new record is created by clicking the End timer button. So what I'm left with in the table, is a row with the file details and a separate row below it with the timer details.
Here is my code:
I am 100% sure where my error is. I'm using DAO.Recordset, CurrentDb.OpenRecordset and rs.AddNew. Which is creating a new record and then updates my text fields with rs.Update. I can tell that's not the right way to go about it. My problem is, I have no idea how to fix it. I am an inexperienced Access/VBA user and this is my first major Database that I've created. So if anyone has the code that can fix this and explain the logic behind it, that would be very constructive for me. Thanks.
P.S. Please check the screenshots for further context. The arrows in the table are indicating where the numbers should actually be, which is pertinent to that record.
To achieve this, I needed to also find a way to track times too. So I went ahead and created timers. The employee's times were recorded using a start and end time.
So how I've gone about doing this is, I've created command buttons for Start, Pause/Unpause and End time.
I have two types of times being tracked:
1. The total time (the total elapsed time from when a user clicks on the Start button and stops the timer by clicking the End button)
2. The actual time (same concept but doesn't record time when the Pause button is clicked; which will be my file processing time)
I have 5 text fields that are running times:
txtSessionStart (the code I've written gives me the Short Date and 24-hr time AM/PM for Start and End time, by clicking the respective Start and End command buttons)
txtActualSeconds
txtActualMinutes
txtTotalSeconds
txtTotalMinutes
I've pretty much got everything working in my VBA code. All command functions work as I intended them to. But I've run into one issue. And it's a pretty big one.
The timer data isn't logging back into the row field pertinent to the current record that the user created. Instead what happens is, a new record is created by clicking the End timer button. So what I'm left with in the table, is a row with the file details and a separate row below it with the timer details.
Here is my code:
Code:
Private Sub cmdEnd_Click()
Dim rs As DAO.Recordset
Me.TimerInterval = 0
Set rs = CurrentDb.OpenRecordset("Select * From tblIndexing")
If Not IsNull(Me.txtSessionStart) And Not IsNull(Me.txtActualSeconds) And Not IsNull(Me.txtActualMinutes) And Not IsNull(Me.txtTotalSeconds) And Not IsNull(Me.txtTotalMinutes) Then
rs.AddNew
rs!StartOfTest = Me.txtSessionStart
rs!EndOfTest = Now()
rs!ActualMinutes = Me.txtActualMinutes
rs!ActualSeconds = Me.txtActualSeconds
rs!TotalMinutes = Me.txtTotalMinutes
rs!TotalSeconds = Me.txtTotalSeconds
rs.Update
End If
rs.Close
Set rs = Nothing
MsgBox "Data logged.", vbOKOnly, "Logged"
End Sub
I am 100% sure where my error is. I'm using DAO.Recordset, CurrentDb.OpenRecordset and rs.AddNew. Which is creating a new record and then updates my text fields with rs.Update. I can tell that's not the right way to go about it. My problem is, I have no idea how to fix it. I am an inexperienced Access/VBA user and this is my first major Database that I've created. So if anyone has the code that can fix this and explain the logic behind it, that would be very constructive for me. Thanks.
P.S. Please check the screenshots for further context. The arrows in the table are indicating where the numbers should actually be, which is pertinent to that record.
Attachments
Last edited: