Link to home
Start Free TrialLog in
Avatar of ecathell
ecathell

asked on

PrinttoPrinter Method of Strongly typed report does not print data

crLoadConfirmation = New LoadConfirmation

                    count = crLoadConfirmation.Database.Tables.Count()
                    Debug.WriteLine("LoadConfirmationCount= " & count)
                    '==============================================
                    'crLoadConfirmation = changeLCReportLocation(crLoadConfirmation)
                    '======================================

                    crParameterDiscreteValue = New ParameterDiscreteValue
                    crParameterDiscreteValue.Value = load

                    crParameterField = New ParameterField
                    crParameterField.ParameterFieldName = "LoadNo"
                    crParameterField.CurrentValues.Add(crParameterDiscreteValue)

                    crParameterFields = New ParameterFields
                    crParameterFields.Add(crParameterField)
                    Me.CrystalReportViewer1.ParameterFieldInfo = crParameterFields
                    Me.CrystalReportViewer1.ReportSource = crLoadConfirmation
                   
                    crLoadConfirmation.PrintToPrinter(1, False, 1, 1)

That is a sample of my code. If i use the same code and open the report in the Report Viewer my data is present. Printing it this way The structure of the report is there, but no data is present.


here is a code sample of wher I use the Report Viewer for the same report:
 ''CR Variables
                    crLoadConfirmation = New LoadConfirmation

                    count = crLoadConfirmation.Database.Tables.Count()
                    Debug.WriteLine("LoadConfirmationCount= " & count)
                    '==============================================
                    'crLoadConfirmation = changeLCReportLocation(crLoadConfirmation)
                    '======================================

                    crParameterDiscreteValue = New ParameterDiscreteValue
                    crParameterDiscreteValue.Value = load

                    crParameterField = New ParameterField
                    crParameterField.ParameterFieldName = "LoadNo"
                    crParameterField.CurrentValues.Add(crParameterDiscreteValue)

                    crParameterFields = New ParameterFields
                    crParameterFields.Add(crParameterField)
                    Me.CrystalReportViewer1.ParameterFieldInfo = crParameterFields
                    Me.CrystalReportViewer1.ReportSource = crLoadConfirmation
Avatar of Mike McCracken
Mike McCracken

The report views ok?  Can you print it from the viewer?

Try
crLoadConfirmation.PrintOut False

mlmcc
 crLoadConfirmation.PrintToPrinter(1, False, 1, 1)

why are yuo printing the only 1st page

if you want to print every page you should use
  crLoadConfirmation.PrintToPrinter(1, False, 0, 0)
and for the sake of it i will run this code before you set the viewer's datasource

Regards
Emre

Avatar of ecathell

ASKER

crLoadConfirmation.SetParameterValue("LoadNo", crParameterDiscreteValue.Value)
                    crLoadConfirmation.PrintToPrinter(1, False, 1, 1)

actually I am printing only one page because there is just one page.

This is the answer to my problem, i discovered it on my own. Because the report is no longer actually using the viewer I have to pass the parameter value to the report and not the viewer control.

Eric
Sounds good
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial