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

selecting a different printer when report is ran from vb

Status
Not open for further replies.

tsd30135

Technical User
Sep 21, 2004
38
US
What do I need to do in order to get a printer selection when I do a print preview of a Crystal 8.5 report.

I have several printers setup on my laptop but only one printer can be used when I want to print.

Crystal 8.5 vb6
 
Here's a couple of threads along those lines:

thread149-773033
thread711-628174

-k
 
Here is the code that was suggested. I am using the viewer code from 8.5 and vb6 but it errors on the printersetup method.

My viewer control is crviewer1, I do not get the method printersetup when I use the "."

TSD


Private Sub CRViewer_PrintButtonClicked(UseDefault As Boolean)

UseDefault = False

'Invoke the Printer Setup dialog
crxRpt.PrinterSetup Me.hWnd

Dim p As Printer
For Each p In Printers
If p.DeviceName = crxRpt.PrinterName Then
crxRpt.SelectPrinter p.DriverName, p.DeviceName, p.Port
Exit For
End If
Next p

crxRpt.PrintOut True, 1

End Sub
 
What's the error, and what operating system are you using?

-dave
 
The error I get is

Runtime error '438'
object doesn't support this property or method.



TSD
 
The above code is for use with the RDC (Report Designer Component), which requires:
1) Your VB Project has a reference to the Crystal Reports 8.5 ActiveX Designer Run Time Library (craxdrt.dll)
2) The app uses a Crystal Viewer Control (crviewer.dll) to display the report.

If you're using some other method to call and view your reports (OCX, API, CRPEAuto, etc.), please state that in your next post. The above code won't work with any of those methods.

So, if you are indeed using the RDC, it could be that you need a hotfix/service pack:
Hot Fixes
Service Packs

Also, please provide the code you're using the open/view the report.

-dave
 
Thanks for the help. I figured out my problem.

I was calling my report like this:
Set crRep = crappl.OpenReport("c:\temp\gpd1.rpt")
crrep is set to "Dim crRep As New CRAXDDRT.Report"

So to get the code to work I needed to use crrep instead of the actual viewer crviewer1.

Thanks for you help

tsd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top