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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vars are incrementing everytime i print a report

Status
Not open for further replies.

easycode

Programmer
Jan 28, 2005
195
0
0
US
Hi all,

I am having a problems it seems to be simple but is not.
Hi have a report, in the detail section i have coded to add according to a certain conditions if the record is good or bad, the problem is that when i run the report in the screen it displays the correct result but whn i send it to print it duplicates the value, and if i print like 5 copies of the report on each copy adds the previous value , e.g.

in screen
goods 65
bads 4
-----
total 69

in first print out
goods 130
bads 8
----
total 138

and in the second print out it keeps adding 65 to the goods and 4 to the bads.

here is the code in case you might need it


Option Compare Database
Dim ctl As Control
Dim fgood As Integer 'fstatus = blank
Dim fbad As Integer 'fstatus = any error like fail letter or wrong rep, etc

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

If Len(Nz(FStatus, "")) <> 0 Then 'if contact has an error
fbad = fbad + 1
For Each ctl In Me.Controls
'text61 and text62 means the page footer the date and the page number that don't need to change the color
If ctl.ControlType = acTextBox And (Not (ctl.Name = "Text61" Or ctl.Name = "Text62" Or ctl.Name = "Date")) Then
ctl.BackStyle = 1
ctl.BackColor = RGB(255, 255, 0)
End If
Next ctl
Else
fgood = fgood + 1
For Each ctl In Me.Controls
If ctl.ControlType = acTextBox Then
ctl.BackStyle = 0
End If
Next ctl
End If
End Sub

Private Sub Report_Open(Cancel As Integer)
fgood = 0
fbad = 0
End Sub

Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
lblgoodqt.Caption = fgood
lblbadqt.Caption = fbad
lbltotalqt.Caption = fgood + fbad
End Sub


Any help is appreciated.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top