Thanks for responding BobWman, but ...
when I now execute the following command, the preview window just flashes and I get no report/data on the screen.
In your original message, I assumed you were getting a report, but the data was not being refreshed. Maybe, I misread your problem. You also asked for sample code. There are many different ways to print/display a crystal report. This example uses the OCX(Crystl32.OCX.
Select Case Index ' cmdPrint button array
Case 0
' To Printer
crpRept.Destination = crptToPrinter
lngResult = crpRept.PrintReport
If lngResult = 0 Then
strMsg = " Done! "
ElseIf lngResult <> 20545 Then ' Cancelled by user
Error lngResult ' Use error handler to save error
'strMsg = crpRept.LastErrorString
End If
Case 1
' To screen
crpRept.Destination = crptToWindow
lngResult = crpRept.PrintReport
If lngResult = 0 Then
strMsg = vbNullString
ElseIf lngResult <> 20545 Then ' Cancelled by user
Error lngResult ' Use error handler to save error
'strMsg = crpRept.LastErrorString
End If
End Select
This solution works perfect as long as there is no subreport inserted on the report. In that case I becom the error: 'Cannot open SQL server'.
(The report and subreport are linked to the same MS ACCESS database but on a different table)
Do I forget something while using a report with a subreport ??
First, does the report run in standalone mode - without VB? We have used code like this to run many reports that include subreports. However, the database used is SQL Server, rather than Access. The code I provided should work fine with SQL Server and/or Access. It also works fine with SQl Server using SubReports. I assume it should work in your environment. I would look elsewhere for the problem.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.