View Single Post
  #9  
Old May 17th, 2010, 02:56 PM posted to microsoft.public.access.reports
Lydia
external usenet poster
 
Posts: 94
Default Report Won't Print

The following are the codes behind the report.
Option Compare Database
Option Explicit
Const conTotalColumns = 8

Dim dbsReport As DAO.Database
Dim rstReport As DAO.Recordset
Dim intColumnCount As Integer

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim intX As Integer
If Not rstReport.EOF Then
If FormatCount = 1 Then
For intX = 1 To intColumnCount - 3
Me("col" + Format(intX)) = rstReport(intX + 2)
Next intX
For intX = intColumnCount - 2 To conTotalColumns
Me("Col" + Format(intX)).Visible = False
Next intX
rstReport.MoveNext

End If
End If
End Sub

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Dim intX As Integer
If InStr(Me("Col3"), "Racing max") 0 Or InStr(Me("Col3"), "Cranking
Max") 0 Then
For intX = 3 To intColumnCount - 3
Me("Col" + Format(intX)).BackColor = 13948116
Next intX
Else
For intX = 3 To intColumnCount - 3
Me("Col" + Format(intX)).BackColor = vbWhite
Next intX
End If
If Me("Col3") = "kv Idling Sigma" Or Me("Col3") = "kv Racing Max" Or
Me("Col3") = "kv Cranking Max" _
Or Me("Col3") = "Resistance (kohm)" Or Me("Col3") = "Test Miles" Then
For intX = 1 To intColumnCount - 5
Me("lnDivide" + Format(intX)).Visible = True
Next intX
For intX = intColumnCount - 4 To 6
Me("lnDivide" + Format(intX)).Visible = False
Next intX
Else
For intX = 1 To 6
Me("lnDivide" + Format(intX)).Visible = False
Next intX
End If
If Me("Col3") = "Check Point" Or Me("Col3") = "Odometer" Or Me("Col3") =
"Test Miles" Then
For intX = 3 To 8
Me("Col" + Format(intX)).FontItalic = True
Me("Col" + Format(intX)).FontBold = True
Next intX
If Me("Col3") = "Check Point" Then
For intX = 3 To 8
Me("Col" + Format(intX)).ForeColor = 16711935
Me("Col" + Format(intX)).FontSize = 12
Next
End If
If Me("Col3") = "Odometer" Then
For intX = 3 To 8
Me("Col" + Format(intX)).ForeColor = 16711680
Me("Col" + Format(intX)).FontSize = 12
Next
End If
If Me("Col3") = "Test Miles" Then
For intX = 3 To 8
Me("Col" + Format(intX)).ForeColor = 0
Me("Col" + Format(intX)).FontSize = 12
Next
End If
Else
For intX = 3 To 8
Me("Col" + Format(intX)).FontItalic = False
Me("Col" + Format(intX)).FontBold = False
Me("Col" + Format(intX)).ForeColor = 0
Me("Col" + Format(intX)).FontSize = 11
Next intX
End If
End Sub

Private Sub Detail_Retreat()
rstReport.MovePrevious
End Sub

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)
If FormatCount = 1 Then
Me("col1") = rstReport(3)
Me("Col2") = rstReport(4)
End If
End Sub
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
pgH1 = rstReport(1) & ": " & Me.OpenArgs
pgH2 = "Vehicle ID: " & rstReport(0)
txtFleet = Me.OpenArgs
End Sub

Private Sub Report_Close()
rstReport.Close
End Sub
Private Sub Report_NoData(Cancel As Integer)
rstReport.Close
Cancel = True
End Sub

Private Sub Report_Open(Cancel As Integer)
On Error GoTo ErrorHandler:
Dim intX As Integer
Dim qdf As QueryDef
Dim frm As Form
' Set database variable to current database.
Set dbsReport = CurrentDb()
Set frm = Forms![frmTestDetailsCriteria]
Me.RecordSource = "qryPartTestDetailsAllCrosstab"
Set qdf = dbsReport.QueryDefs("qryPartTestDetailsAllCrosstab ")
qdf.Parameters("Forms!frmTestDetailsCriteria!cmb_V ehicleID") _
= frm!cmb_VehicleID
qdf.Parameters("Forms!frmTestDetailsCriteria!cmbRe questNo") _
= frm!cmbRequestNo
' Open Recordset object.
Set rstReport = qdf.OpenRecordset()
rstReport.MoveFirst

' Set a variable to hold number of columns in crosstab query.
intColumnCount = rstReport.Fields.Count
ErrorHandlerExit:
Exit Sub
ErrorHandler:
Dim strErrDesc As String
If Right(Err.Description, 1) = "." Then
strErrDesc = Err.Description
Else
strErrDesc = Err.Description & "."
End If

MsgBox "Error: " & Err & " occurred: " & strErrDesc
Resume ErrorHandlerExit:
End Sub

--
Lydia Liu
Access/VB Programmer



"Duane Hookom" wrote:

I can't see any of your code or how you have created the report. Was this
one of my report samples?

--
Duane Hookom
MS Access MVP


"Lydia" wrote in message
...
Duane,

I have a report that is based on a crosstab query. When I preview it, it
opens up Ok. However when I print it, an error message comes up saying: A
custome macro
in this report has failed to run and is preventing report from rendering.

This seems to be caused by the line rstreport.movenext where rstreport is
recordset. Since if I remove this line, the report will print, of course
the
same line over and over again. As soon as I add it back, the error comes
back.

Any idea why this happens?

Thanks.



--
Lydia Liu
Access/VB Programmer



"Duane Hookom" wrote:

Some times objects (tables, forms, reports,...) become corrupt...
--
Duane Hookom
Microsoft Access MVP


"Frank Wagner" wrote:

Duane:

I checked the settings, and both reports were set for the default
printer.
The whole thing is so puzzling that I decided to try the old standby -
recreate the report. It worked. I created a new report, and copied
the
controls from the old report to the new. Who knows why, but this one
prints
like a charm.

Thanks for your help
--
Frank Wagner



"Duane Hookom" wrote:

To determine the printer from design view, select File-Page
Setup-Page tab.
If you can't figure out the issue, then provide more details. It
doesn't help
us to know there is code without knowing the code.

--
Duane Hookom
Microsoft Access MVP


"Frank Wagner" wrote:

Duane:

Both reports are called from forms, and work off select queries
that select
ID #'s from those forms. Each report contains a subreport that
selects
records keyed to the same ID # as the main report. I am not sure
if they are
both connected to the default printer and I'm not sure how to
determine that.

They both open in design view, and have small amounts of VBA code
supporting
them. I hope this helps. The default printer may be a problem.
How do I
find that setting/

Thanks for your interest in helping me.
--
Frank Wagner



"Duane Hookom" wrote:

What else can you tell us about the reports and what have you
tried? Do they
both open in design view? Do they have any code? Are they both
set to print
to the default printer? Do the record sources both return
records?
--
Duane Hookom
Microsoft Access MVP


"Frank Wagner" wrote:

I have two reports that I have created using Access2000. One
will print, and
nothing happens when I click print on the other report. I've
checked the
properties of both reports, and they appear to be the same.

I'm stuck and any help would be appreciated

Thanks

Frank Wagner
--
Frank Wagner