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

Cyrstal report XI not printing in landscape.

Status
Not open for further replies.

AGIMA

Programmer
Jul 24, 2003
95
AU
I have a VB6 application that prints Cyrstal reports XI, however one of the reports is setup to print landscape and prints OK from the crystal designer interface, however when the same report is printed from within the VB6 application it comes out portrait.

Am I missing some setting on the Crystal viewer?

Thanks in advance.

AGIMA - professional web hosting is our business.

AGIMA Computing
 
Have you tried:

.PaperOrientation = 2

'DefaultPaperOrientation = 0
'Portrait = 1
'Landscape = 2
 
Here's a complete example:

Code:
Private Sub Command1_Click()

   'Print a saved Crytal Report

   'Visual Basic 6.0

   'Crystal reports 8.0

   Dim rsTempRecordset As New ADODB.Recordset

   Dim CR_CustomApp As New CRAXDRT.Application

   Dim CR_CustomReport As CRAXDRT.Report

   Dim prn As Printer
  

   'Using SQL 2000

   With cnCMS

       .CursorLocation = adUseClient

       .ConnectionString = "MSDASQL.1;Persist Security Info=True;" & _
       "User ID=sa;Password='';Data Source=CMS"

       .Open

   End With

   'You can use the data saved with the report.  I want it fresh everytime.

   With rsTempRecordset

      If .State = adStateOpen Then

          .Close

      End If

      .ActiveConnection = cnCMS

      .LockType = adLockOptimistic

      .Source = "Select * from ScanDocumentsErrors "

      .Open

   End With

   Set CR_CustomReport = CR_CustomApp.OpenReport("c:\@@crystal\TwainReport.rpt", 1)

   'Use can use the printer saved with the report and skip this part.  Or

   'use the loop to display the printer avaiable to you.  Mine were:

   ' Availble Printer names:
        ' TPA
        ' Federal
        ' hp LaserJet
        ' State

   For Each prn In Printers

      If prn.DeviceName Like "*LaserJet*" Then

         Set Printer = prn

         Exit For

      End If

   Next
 

   CR_CustomReport.SelectPrinter prn.DriverName, prn.DeviceName, prn.Port
   'Get rid of saved date

   CR_CustomReport.DiscardSavedData

   'Use can use the orientation saved with the report or override it.

   'DefaultPaperOrientation = 0
   'Portrait = 1
   'Landscape = 2
   CR_CustomReport.PaperOrientation = 2

   CR_CustomReport.Database.SetDataSource rsTempRecordset

   CR_CustomReport.PrintOut False

   Set CR_CustomReport = Nothing

   Set rsTempRecordset = Nothing

   cnCMS.Close
    

End Sub




 
thanks for the code sample. I guess I can force the printing by using that method.

I would of thought that the report would of used the orientation that was saved with the report. It is saved with landscape but does not print out that way.



AGIMA - professional web hosting is our business.

AGIMA Computing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top