G
Guest
I've run into a odd issue with a running total field. I am calling a VBA
script from the reports Detail section in the On Format event. I need to
perform the running total here, because I am using the running total to
compare against estimated available hours after each iteration.
The variables [tmpSumEmpHours] and [tmpTotEmpHours] are defined as private:
-----------------------
Option Compare Database
Option Explicit
Private tmpTotEmpHours As Single
Private tmpSumEmpHours As Single
-----------------------
The code that increments [tmpSumEmpHours] is as follows:
-----------------------
If tmpRescName = Me.RescName Then
If tmpSumEmpHours > 0 Then
tmpSumEmpHours = tmpSumEmpHours + tmpTotEmpHours
Else
tmpSumEmpHours = tmpTotEmpHours
End If
Else
tmpSumEmpHours = tmpTotEmpHours
End If
-----------------------
There are two unique (but related) situations that occur when the report
starts on a new page. The problem does not occur on the first page:
1) If the RescName is the same, on a new page, on the first line ONLY of the
page, 2 x [tmpTotEmpHours] are added to [tmpSumEmpHours]. Why? On all
subsequent lines on the page the math works correctly.
2) If the RescName is not the same (i.e. a new RescName), 2 x
[tmpTotEmpHours] are added to [tmpSumEmpHours]. First line only again.
Again... why? On all subsequent lines on the page the math works correctly.
Could someone point me in the direction to look, or could this possibly be a
wierd bug with Access?
script from the reports Detail section in the On Format event. I need to
perform the running total here, because I am using the running total to
compare against estimated available hours after each iteration.
The variables [tmpSumEmpHours] and [tmpTotEmpHours] are defined as private:
-----------------------
Option Compare Database
Option Explicit
Private tmpTotEmpHours As Single
Private tmpSumEmpHours As Single
-----------------------
The code that increments [tmpSumEmpHours] is as follows:
-----------------------
If tmpRescName = Me.RescName Then
If tmpSumEmpHours > 0 Then
tmpSumEmpHours = tmpSumEmpHours + tmpTotEmpHours
Else
tmpSumEmpHours = tmpTotEmpHours
End If
Else
tmpSumEmpHours = tmpTotEmpHours
End If
-----------------------
There are two unique (but related) situations that occur when the report
starts on a new page. The problem does not occur on the first page:
1) If the RescName is the same, on a new page, on the first line ONLY of the
page, 2 x [tmpTotEmpHours] are added to [tmpSumEmpHours]. Why? On all
subsequent lines on the page the math works correctly.
2) If the RescName is not the same (i.e. a new RescName), 2 x
[tmpTotEmpHours] are added to [tmpSumEmpHours]. First line only again.
Again... why? On all subsequent lines on the page the math works correctly.
Could someone point me in the direction to look, or could this possibly be a
wierd bug with Access?