Dear All,
Thanks for a great forum with great people!
I have a problem...
I have a form Employees
form Employees has a subform DatesSubform
I have several fields on the subform DatesSubformDetails area.
EmployeeID
Date
TimeInMorning
TimeOutLunch
TimeInLunch
TimeOutEvening
txtTimeDoneMorning
txtTimeDoneEvening
txtTotalTimeDone
txtTimeRequired
txtFlexi
I then have a field on the DatesSubform form footer.
RollingTime
The RollingTime is meant to show the total of txtFlexi.
I have the following module code from a module called :modRunSum
And then in the subform I have the code:
I keep getting a total of 0.00...where it should be 2:00:00 or 2.
Please help it is a hum dinger.
Thank you!![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
Thank you,
Kind regards
Triacona
Thanks for a great forum with great people!
I have a problem...
I have a form Employees
form Employees has a subform DatesSubform
I have several fields on the subform DatesSubformDetails area.
EmployeeID
Date
TimeInMorning
TimeOutLunch
TimeInLunch
TimeOutEvening
txtTimeDoneMorning
txtTimeDoneEvening
txtTotalTimeDone
txtTimeRequired
txtFlexi
I then have a field on the DatesSubform form footer.
RollingTime
The RollingTime is meant to show the total of txtFlexi.
I have the following module code from a module called :modRunSum
Code:
[blue]Option Compare Database[/blue]
[blue]Option Explicit[/blue]
[blue]Public Function [/blue]frmRunSum(frm As Form, pkName As String, sumName As String)
Dim rst As DAO.Recordset, fld As DAO.Field, subTotal
Set rst = frm.RecordsetClone
Set fld = rst(sumName)
'Set starting point.
rst.FindFirst "[" & pkName & "] = " & frm(pkName)
[green] 'Running Sum (subTotal) for each record group occurs here.
'After the starting point is set, we sum backwards to record 1.[/green]
[blue] If Not [/blue]rst.BOF [blue]Then[/blue]
[blue] Do Until[/blue] rst.BOF
subTotal = subTotal + Nz(fld, 0)
rst.MovePrevious
[blue] Loop
Else[/blue]
subTotal = 0
[blue] End If[/blue]
frmRunSum = subTotal
Set fld = Nothing
Set rst = Nothing
[blue]End Function[/blue]
And then in the subform I have the code:
Code:
[blue]Private Function [/blue]SubSum()
[green]'*************************************************************
'* pkName - Existing unique fieldname (usually primarykey) *
'* sumName - Name of the field to runsum *
'*************************************************************[/green]
[blue] If [/blue]Trim(Me!EmployeeID & "") <> "" Then [green]'Skip New Record![/green]
SubSum = frmRunSum(Me, "EmployeeID", "RollingTime")
[blue] End If[/blue]
[blue]End Function[/blue]
I keep getting a total of 0.00...where it should be 2:00:00 or 2.
Please help it is a hum dinger.
Thank you!
![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
Thank you,
Kind regards
Triacona