D
David C. Holley
I have got a report where the records extend beyond the ranges of the report
period. So if the report period is 3/1 - 3/31, you might have the following
records in the report. Since we are only concerned about time frame that the
records fall within the report, I am manipulating the report to adjust the
Start or End that is DISPLAYED on the report
ACTUAL RECORDS
RecordId Start End
1001 2/25 3/15
1002 3/15 3/31
1003 3/25 4/25
RECORDS AS DISPLAYED
RecordId Start End
1001 3/1 3/15
1002 3/15 3/31
1003 3/25 3/31
Because of this, I am having to programically calculate the duration to
adjust for situations where the date extends outside of the report range.
The problem that I am having is that totals for the report that I am
calculating are not adding up when I add them up manually. The individual
detail records are correct mathmatically, but the value of the total is not
correct.
The total is being obtained using a variable at the module level that is
increased as the Detail_Format event occurs.
And yes, I know that the dates are hardcoded it is a temporary fix until I
can fully automate the report. The (+1) is there because we are dealing with
actual calendar dates, not the number of days in between the dates.
Option Compare Database
Option Explicit
Dim mReportTitle As String
Dim TotalNumberOfDaysForReport As Long
Dim TotalForPage As Long
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Working fine
'MinOfdteTrailerLoadDate is not visible in the report, the value is
pulled and
'placed into dspTrailerLoadDate which is
If Me.MinOfdteTrailerLoadDate < #3/1/2010# Then
Me.dspTrailerLoadDate = "3/1/10"
Else
Me.dspTrailerLoadDate = Me.MinOfdteTrailerLoadDate
End If
'Working fine
'MaxOfdteTrailerUnloadDate is not visible in the report, the value is
pulled and
'placed into dspTrailerUnoadDate which is
If Me.MaxOfdteTrailerUnloadDate > #3/31/2010# Then
Me.dspTrailerUnloadDate = "3/31/10"
Else
Me.dspTrailerUnloadDate = Me.MaxOfdteTrailerUnloadDate
End If
'Calculate the values only once in the event that the section is
formated more than once
If FormatCount = 1 Then
'Number of calendar days
dspExprTotalNumberOfDays = DateDiff("d",
CDate(Me.dspTrailerLoadDate), CDate(Me.dspTrailerUnloadDate)) + 1
'Should be calculating a running total over the detail here
TotalNumberOfDaysForReport = TotalNumberOfDaysForReport +
dspExprTotalNumberOfDays
'Should be calculating a running total over the page here (temporary
for debuging)
TotalForPage = TotalForPage + dspExprTotalNumberOfDays
End If
End Sub
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
'Show the total for the page (temporary)
If FormatCount = 1 Then
Me.Test = TotalForPage
TotalForPage = 0
End If
End Sub
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Me.dspTotalNumberOfDaysForAllTrailers = TotalNumberOfDaysForReport
End Sub
period. So if the report period is 3/1 - 3/31, you might have the following
records in the report. Since we are only concerned about time frame that the
records fall within the report, I am manipulating the report to adjust the
Start or End that is DISPLAYED on the report
ACTUAL RECORDS
RecordId Start End
1001 2/25 3/15
1002 3/15 3/31
1003 3/25 4/25
RECORDS AS DISPLAYED
RecordId Start End
1001 3/1 3/15
1002 3/15 3/31
1003 3/25 3/31
Because of this, I am having to programically calculate the duration to
adjust for situations where the date extends outside of the report range.
The problem that I am having is that totals for the report that I am
calculating are not adding up when I add them up manually. The individual
detail records are correct mathmatically, but the value of the total is not
correct.
The total is being obtained using a variable at the module level that is
increased as the Detail_Format event occurs.
And yes, I know that the dates are hardcoded it is a temporary fix until I
can fully automate the report. The (+1) is there because we are dealing with
actual calendar dates, not the number of days in between the dates.
Option Compare Database
Option Explicit
Dim mReportTitle As String
Dim TotalNumberOfDaysForReport As Long
Dim TotalForPage As Long
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'Working fine
'MinOfdteTrailerLoadDate is not visible in the report, the value is
pulled and
'placed into dspTrailerLoadDate which is
If Me.MinOfdteTrailerLoadDate < #3/1/2010# Then
Me.dspTrailerLoadDate = "3/1/10"
Else
Me.dspTrailerLoadDate = Me.MinOfdteTrailerLoadDate
End If
'Working fine
'MaxOfdteTrailerUnloadDate is not visible in the report, the value is
pulled and
'placed into dspTrailerUnoadDate which is
If Me.MaxOfdteTrailerUnloadDate > #3/31/2010# Then
Me.dspTrailerUnloadDate = "3/31/10"
Else
Me.dspTrailerUnloadDate = Me.MaxOfdteTrailerUnloadDate
End If
'Calculate the values only once in the event that the section is
formated more than once
If FormatCount = 1 Then
'Number of calendar days
dspExprTotalNumberOfDays = DateDiff("d",
CDate(Me.dspTrailerLoadDate), CDate(Me.dspTrailerUnloadDate)) + 1
'Should be calculating a running total over the detail here
TotalNumberOfDaysForReport = TotalNumberOfDaysForReport +
dspExprTotalNumberOfDays
'Should be calculating a running total over the page here (temporary
for debuging)
TotalForPage = TotalForPage + dspExprTotalNumberOfDays
End If
End Sub
Private Sub PageFooterSection_Format(Cancel As Integer, FormatCount As
Integer)
'Show the total for the page (temporary)
If FormatCount = 1 Then
Me.Test = TotalForPage
TotalForPage = 0
End If
End Sub
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Me.dspTotalNumberOfDaysForAllTrailers = TotalNumberOfDaysForReport
End Sub