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

Open a Crystal Reports report with fresh data

Status
Not open for further replies.

diel011

Programmer
Apr 10, 2002
7
0
0
BE
Hello all,

Can somebody give me a simple example on how to open a Crystal Reports report in VB6 with refreshed data on it.

Thanks a lot !!

David
 
I'm not sure what the problem is, but try this.

Using Crystal Reports, open the report file. On the File menu, make sure "Save Data With Report" is unchecked.

Save the report.
 
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.

lesfiche.PrintReport

Can you give me a hint ??

David
 
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
 
Hello BobWman,

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 ??

David
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top