K
Kevin Bruce
This should be simple, I hope.
I have a report with a text box in the footer of an invoice (report) that
holds the total for all the items in the detail section. Because the
individual items and the total are calculated differently depending on
certain conditions, all amounts are calculated using VBA.
When the invoiced is previewed on screen, the total appears as is should be.
When it prints, however, it prints exactly double the true total or twice
what it appears as while in Preview.
My code is below. I have added extra notes in CAPS, and have omitted the
code that produces different amounts and totals under different conditions.
Thanks in advance for any advice.
_Kevin
'---------------------------------------------------------------------------
--------------------
Option Compare Database
Dim curInvoiceTotal As Currency
Dim curFeeThisArtistOwing As Currency
Dim curFeeThisArtistPaid As Currency
'---------------------------------------------------------------------------
-----------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'calculate District Booking Fees
'THIS ITEMIZES EACH ITEM ON THE INVOICE AND CALCULATES A TOTAL FOR EACH
'IT WORKS JUST FINE
If txtEventsAlreadyInvoiced = 0 Then
curFeeThisArtistOwing = 30 + (txtNoOfEvents - 1) * 10
If curFeeThisArtistOwing > 125 Then
curFeeThisArtistOwing = 125
End If
Else
curFeeThisArtistPaid = 30 + (txtEventsAlreadyInvoiced - 1) * 10
If curFeeThisArtistPaid > 125 Then
curFeeThisArtistPaid = 125
End If
curFeeThisArtistOwing = txtNoOfEvents * 10
If curFeeThisArtistOwing + curFeeThisArtistPaid > 125 Then
curFeeThisArtistOwing = 125 - curFeeThisArtistPaid
End If
End If
'THIS ASSIGNS THE VALUE CALCULATED ABOVE TO THE TEXT BOX IN THE DETAIL
'SECTION ON THE INVOICE. NO PROBLEMS HERE.
txtSDBookingFeeThisArtist = curFeeThisArtistOwing
'---------------------------------------------------------------------------
--------------------------
Private Sub Detail_Print(Cancel As Integer, FormatCount As Integer)
'add fee owing per artist to the invoice total
'THIS IS MY ATTEMPT TO SUM THE FEES CALCULATED IN THE DETAIL FORMAT 'SECTION
ABOVE
curInvoiceTotal = curInvoiceTotal + curFeeThisArtistOwing
End Sub
'---------------------------------------------------------------------------
--------------------------
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
'THIS ASSIGNS THE TOTAL TO THE VALUE OF THE TEXT BOX ON THE INVOICE.
'IN PRINT PREVIEW, THE TOTAL IS EXACTLY WHAT IT SHOULD BE
'WHEN IT PRINTS, THE TOTAL IS EXACTLY DOUBLE WHAT IT IS IN PREVIEW
txtInvoiceTotal = curInvoiceTotal
I have a report with a text box in the footer of an invoice (report) that
holds the total for all the items in the detail section. Because the
individual items and the total are calculated differently depending on
certain conditions, all amounts are calculated using VBA.
When the invoiced is previewed on screen, the total appears as is should be.
When it prints, however, it prints exactly double the true total or twice
what it appears as while in Preview.
My code is below. I have added extra notes in CAPS, and have omitted the
code that produces different amounts and totals under different conditions.
Thanks in advance for any advice.
_Kevin
'---------------------------------------------------------------------------
--------------------
Option Compare Database
Dim curInvoiceTotal As Currency
Dim curFeeThisArtistOwing As Currency
Dim curFeeThisArtistPaid As Currency
'---------------------------------------------------------------------------
-----------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
'calculate District Booking Fees
'THIS ITEMIZES EACH ITEM ON THE INVOICE AND CALCULATES A TOTAL FOR EACH
'IT WORKS JUST FINE
If txtEventsAlreadyInvoiced = 0 Then
curFeeThisArtistOwing = 30 + (txtNoOfEvents - 1) * 10
If curFeeThisArtistOwing > 125 Then
curFeeThisArtistOwing = 125
End If
Else
curFeeThisArtistPaid = 30 + (txtEventsAlreadyInvoiced - 1) * 10
If curFeeThisArtistPaid > 125 Then
curFeeThisArtistPaid = 125
End If
curFeeThisArtistOwing = txtNoOfEvents * 10
If curFeeThisArtistOwing + curFeeThisArtistPaid > 125 Then
curFeeThisArtistOwing = 125 - curFeeThisArtistPaid
End If
End If
'THIS ASSIGNS THE VALUE CALCULATED ABOVE TO THE TEXT BOX IN THE DETAIL
'SECTION ON THE INVOICE. NO PROBLEMS HERE.
txtSDBookingFeeThisArtist = curFeeThisArtistOwing
'---------------------------------------------------------------------------
--------------------------
Private Sub Detail_Print(Cancel As Integer, FormatCount As Integer)
'add fee owing per artist to the invoice total
'THIS IS MY ATTEMPT TO SUM THE FEES CALCULATED IN THE DETAIL FORMAT 'SECTION
ABOVE
curInvoiceTotal = curInvoiceTotal + curFeeThisArtistOwing
End Sub
'---------------------------------------------------------------------------
--------------------------
Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
'THIS ASSIGNS THE TOTAL TO THE VALUE OF THE TEXT BOX ON THE INVOICE.
'IN PRINT PREVIEW, THE TOTAL IS EXACTLY WHAT IT SHOULD BE
'WHEN IT PRINTS, THE TOTAL IS EXACTLY DOUBLE WHAT IT IS IN PREVIEW
txtInvoiceTotal = curInvoiceTotal