I have a form used to generate reports. It loops over a recordset and prints the reports to a postscript or .pdf file. The report will preview correctly in Crystal, but not Access 2000. At best, it will show the first page of the report, but the report file need to be open in Crystal to even get that far. If Crystal is not open, the preview window flashes by and nothing happens.
The Crystal Report Control is set as a reference on the form.
Thanks for any help.
Here is the code:
Private Sub btnPrintMe_Click()
Dim dbs As Connection
Dim rstPrintThis As New ADODB.Recordset
Dim strDeleteThis As String
Dim strInsertThis As String
Dim strReportName As String
Dim intPrint As Integer
Dim intRecCount As Integer
Set dbs = CurrentProject.Connection
rstPrintThis.Open "SELECT * FROM participantList where empid=32731 ORDER BY empID", dbs, adOpenStatic
DoCmd.SetWarnings False
rstPrintThis.MoveLast
intRecCount = rstPrintThis.RecordCount
rstPrintThis.MoveFirst
Do Until rstPrintThis.EOF
strDeleteThis = "DELETE FROM reportIDList"
DoCmd.RunSQL (strDeleteThis)
strReportName = "c:\temp\in\" & Trim(Str(rstPrintThis!empID)) & ".pdf"
Debug.Print rstPrintThis!empID
strInsertThis = "INSERT INTO reportIDList (currentRptID) VALUES (" & Str(rstPrintThis!empID) & ""
Debug.Print strReportName
DoCmd.RunSQL (strInsertThis)
With crystalRptControl
.ReportFileName = "C:\currentjobs\\IndividualReportFinal.rpt"
.Destination = crptToWindow
.PrintReport
End With
'SendKeys "c:\temp\in\" & Trim(Str(rstPrintThis!empID)) & ".pdf{ENTER}"
'crystalRptControl.PrintReport
rstPrintThis.MoveNext
Loop
DoCmd.SetWarnings True
End Sub
The Crystal Report Control is set as a reference on the form.
Thanks for any help.
Here is the code:
Private Sub btnPrintMe_Click()
Dim dbs As Connection
Dim rstPrintThis As New ADODB.Recordset
Dim strDeleteThis As String
Dim strInsertThis As String
Dim strReportName As String
Dim intPrint As Integer
Dim intRecCount As Integer
Set dbs = CurrentProject.Connection
rstPrintThis.Open "SELECT * FROM participantList where empid=32731 ORDER BY empID", dbs, adOpenStatic
DoCmd.SetWarnings False
rstPrintThis.MoveLast
intRecCount = rstPrintThis.RecordCount
rstPrintThis.MoveFirst
Do Until rstPrintThis.EOF
strDeleteThis = "DELETE FROM reportIDList"
DoCmd.RunSQL (strDeleteThis)
strReportName = "c:\temp\in\" & Trim(Str(rstPrintThis!empID)) & ".pdf"
Debug.Print rstPrintThis!empID
strInsertThis = "INSERT INTO reportIDList (currentRptID) VALUES (" & Str(rstPrintThis!empID) & ""
Debug.Print strReportName
DoCmd.RunSQL (strInsertThis)
With crystalRptControl
.ReportFileName = "C:\currentjobs\\IndividualReportFinal.rpt"
.Destination = crptToWindow
.PrintReport
End With
'SendKeys "c:\temp\in\" & Trim(Str(rstPrintThis!empID)) & ".pdf{ENTER}"
'crystalRptControl.PrintReport
rstPrintThis.MoveNext
Loop
DoCmd.SetWarnings True
End Sub