JoseC
Programmer
- Dec 11, 2001
- 18
Environment: VB6, SQL 7.0, CR6.0 OCX
Using the following, I can get the report to PrintPreview okay. But it keeps the connection open.
This VB app is a Print Engine, I pass data to it and it displays in PrintPreview to user.
1. How do I close the connection without terminating this VB app?
'-------------------------- CODE ------------------------
with CrystalReports
.ReportFileName = reportparameters("reportfilename"
.SQLQuery = reportparameters("sqlquery"
.Connect = "Provider=SQLOLEDB;SERVER=" & MSSQL_DB & ";DATABASE=MyDB; UID=myUID; PWD=myPWD"
.Destination = crptToWindow
.WindowShowZoomCtl = True
.WindowShowRefreshBtn = False
.WindowShowNavigationCtls = True
.WindowState = crptMaximized
.WindowTitle = "Print Preview: " & reportparameters("reportname"
.printreport
end with
Do
lWindowID = FindWindow(vbNullString, "Print Preview: " & reportparameters("reportname"
)
If lWindowID = 0 Then: Exit Do 'if window has been closed/terminated then exit this Do..Loop, then exit sub.
DoEvents
Loop
'-------------------------- CODE ------------------------
Thanks!
Using the following, I can get the report to PrintPreview okay. But it keeps the connection open.
This VB app is a Print Engine, I pass data to it and it displays in PrintPreview to user.
1. How do I close the connection without terminating this VB app?
'-------------------------- CODE ------------------------
with CrystalReports
.ReportFileName = reportparameters("reportfilename"
.SQLQuery = reportparameters("sqlquery"
.Connect = "Provider=SQLOLEDB;SERVER=" & MSSQL_DB & ";DATABASE=MyDB; UID=myUID; PWD=myPWD"
.Destination = crptToWindow
.WindowShowZoomCtl = True
.WindowShowRefreshBtn = False
.WindowShowNavigationCtls = True
.WindowState = crptMaximized
.WindowTitle = "Print Preview: " & reportparameters("reportname"
.printreport
end with
Do
lWindowID = FindWindow(vbNullString, "Print Preview: " & reportparameters("reportname"
If lWindowID = 0 Then: Exit Do 'if window has been closed/terminated then exit this Do..Loop, then exit sub.
DoEvents
Loop
'-------------------------- CODE ------------------------
Thanks!