I
itHeiner
I have a mysql database that I connect Access to. I use access to generate
time cards for employees. One the class modules I have contains a function
that adds up the total hours a person worked in a day. My problem occurs
when I use a select statement to add the times together. Here is the code:
Public Function calculateDailyTotal(ByVal userid As String, ByVal
clockOutDate As String) As String
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim recAddedTime As DAO.Recordset
Dim tempVar1 As String
Dim tempVar2 As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("select total_time_per_session from
recorded_work where user_id='" & userid & "' and clock_out_date='" &
clockOutDate & "' and total_time_per_session is not null;")
tempVar2 = "00:00"
Do Until rec.EOF
tempVar1 = rec("total_time_per_session")
selectStr = "select addtime('" & tempVar2 & "', '" & tempVar1 & "')"
Set recAddedTime = db.OpenRecordset(selectStr)
tempVar2 = recAddedTime(0)
rec.MoveNext
Loop
calculateDailyTotal = tempVar2
End Function
The error message I get tells me that the function or procedure addtime
doesn't exist or is invalid. I know it work because I go to my mysql
terminal and type it in and it works. There may be other errors with the
code, but I have been focusing on the select statement at the moment. If
anyone can help, it would be much appreciated.
time cards for employees. One the class modules I have contains a function
that adds up the total hours a person worked in a day. My problem occurs
when I use a select statement to add the times together. Here is the code:
Public Function calculateDailyTotal(ByVal userid As String, ByVal
clockOutDate As String) As String
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim recAddedTime As DAO.Recordset
Dim tempVar1 As String
Dim tempVar2 As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("select total_time_per_session from
recorded_work where user_id='" & userid & "' and clock_out_date='" &
clockOutDate & "' and total_time_per_session is not null;")
tempVar2 = "00:00"
Do Until rec.EOF
tempVar1 = rec("total_time_per_session")
selectStr = "select addtime('" & tempVar2 & "', '" & tempVar1 & "')"
Set recAddedTime = db.OpenRecordset(selectStr)
tempVar2 = recAddedTime(0)
rec.MoveNext
Loop
calculateDailyTotal = tempVar2
End Function
The error message I get tells me that the function or procedure addtime
doesn't exist or is invalid. I know it work because I go to my mysql
terminal and type it in and it works. There may be other errors with the
code, but I have been focusing on the select statement at the moment. If
anyone can help, it would be much appreciated.