Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when im printing my report

Status
Not open for further replies.

hdesbiens

Programmer
May 2, 2004
77
CA
Hi

i have a weird problem and really dont understand what is happening.

I have a report and when i preview it i see that
sub total 209.95
total before taxes 209.95
tax1 14.70
tax2 16.85
Total 241.50

But when i send it to the printer it doubles my totals like this
sub total 419.90
total before taxes 419.90
tax1 29.39
tax2 33.70
Total 482.99

Could someone help me find the way to fix this?

thanks a lot
 
hdesbiens
You're right. That is weird.

Some questions...
1. Does this happen with only that one report? Or with all reports?
2. If you send it directly to the printer, say from a command button on a form, rather than Preview, do you get the same "doubling?"
3. Is there code behind the report that could cause an issue upon printint?

You could try rebuilding the report and see if it still happens.

Tom
 
Hi THWatson

heres the answer to your questions:

1- it only happens with this report, its an invoice
2- if i send it directly to the printer there is no doubling
3- i think this is the code that is generating the issue but dont understand why!! heres the code:

Option Compare Database
Public PageSum, SommeMontantTotal, MontantTotAvTax, MontantTvq, MontantTps, MontantTotal As Currency
Private Sub Détail_Print(Cancel As Integer, PrintCount As Integer)
PageSum = PageSum + Me.SoutTotal
If Me.NoItem = "" Or IsNull(Me.NoItem) Then
Me.Vendant.Visible = False
Me.SoutTotal.Visible = False
Else
Me.Vendant.Visible = True
Me.SoutTotal.Visible = True
End If
End Sub

Private Sub Report_Open(Cancel As Integer)
SommeMontantTotal = 0
MontantTotAvTax = 0
MontantTps = 0
MontantTvq = 0
MontantTotal = 0
Me.etmtavtx.Visible = False
Me.mttotalavtx.Visible = False
Me.mttps.Visible = False
Me.mttvq.Visible = False
Me.mttotal.Visible = False
End Sub

Private Sub ZonePiedPage_Format(Cancel As Integer, FormatCount As Integer)
SommeMontantTotal = SommeMontantTotal + PageSum
If Me.Page = Me.Pages Then
'Cancel = True
Me.etmtavtx.Visible = True
Me.mttotalavtx.Visible = True
Me.mttps.Visible = True
Me.mttvq.Visible = True
Me.mttotal.Visible = True
MontantTotAvTax = SommeMontantTotal
MontantTps = Round(MontantTotAvTax * (0.07), 2)
MontantTvq = Round((SommeMontantTotal + MontantTps) * (0.075), 2)
MontantTotal = SommeMontantTotal + MontantTvq + MontantTps
Me.mttotalavtx = MontantTotAvTax
Me.mttps = MontantTps
Me.mttvq = MontantTvq
Me.mttotal = MontantTotal
SommeMontantTotal = 0
Else
Me.etmtavtx.Visible = False
Me.mttotalavtx.Visible = False
Me.mttps.Visible = False
Me.mttvq.Visible = False
Me.mttotal.Visible = False
End If
End Sub

Private Sub ZonePiedPage_Print(Cancel As Integer, PrintCount As Integer)
'SommeMontantTotal = SommeMontantTotal + PageSum
Me.mttotalavtx = 0
Me.mttps = 0
Me.mttvq = 0
Me.mttotal = 0
If Me.Page = Me.Pages Then
'Cancel = True
Me.etmtavtx.Visible = True
Me.mttotalavtx.Visible = True
Me.mttps.Visible = True
Me.mttvq.Visible = True
Me.mttotal.Visible = True
Me.mttotalavtx = MontantTotAvTax
Me.mttps = MontantTps
Me.mttvq = MontantTvq
Me.mttotal = MontantTotal
SommeMontantTotal = 0
Else
Me.etmtavtx.Visible = False
Me.mttotalavtx.Visible = False
Me.mttps.Visible = False
Me.mttvq.Visible = False
Me.mttotal.Visible = False
End If
End Sub

Thanks a lot!
 
Most interesting!

In checking the link that CosmoKramer provided, the Microsoft site indicates this is an issue for Access 97. Maybe it occurs in later versions as well. I use Access 2000 and never encountered that problem. But since it occurs only when you Preview and then Print, it does appear the issue is affecting your project.

Tom

 
Like the MS page says:
You are programmatically calculating your totals. The totals are calculated by using a report event that fires per page. Each page must be previewed to fire that event for that page and then calculate the correct totals.

Do you have to preview it before printing?? If you do have to you might want to consider this option:

I inherited a database a few years ago where the same problem was noticed and I didn't have the time to try to go in and fix it properly. Since this was basically a single-user app we decided to go the route of having two print buttons on the form, one for preview, the other for printing directly. While not elegant, or fool-proof (the user could still print from print preview), this method worked for us in this situation....

Si hoc legere scis, nimis eruditionis habes
 
That being the case, it would appear that this problem may well carry over into later versions of Access.

CosmoKramer's solution sounds like a good one!


Tom
 
hdesbiens
I just had a look at your code again and am wondering about something.

You have identical code in both the Format and the Print events for the Page. Therefore, is it the case that in Preview mode the page is prepared by the Format event, and then when you tell it to Print from the Preview mode the Print event kicks in also, thus causing the doubling?

What happens if you comment out the code in the Print event, and then print it from the Preview mode?

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top