Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Crystal Reports 9.0 on VB .NET Report Won't Print Correctly


Closed Thread
 
Thread Tools Display Modes
  #1  
Old 09-08-2003, 11:18 AM
ccherry ccherry is offline
Freshman
 
Join Date: Jul 2003
Posts: 26
Question Crystal Reports 9.0 on VB .NET Report Won't Print Correctly


I'm using Crystal Reports 9 with VB.NET in which I'm using a form called, "frmShowReport." It is simply a form with a CrystalReportViewer control placed on it. I have set the ReportSource in that control to be crystalreport11, which is my .rpt file. The above function sets up the SQL statement inside of the report and then brings up the CrystalReportViewer. This all works great. The new form pops up and the report performs exactly as expected.

My problem, however, comes when I try to print this report from the Viewer. I press the print button from the viewer, hit OK when the print options come up and it does send the report to my laser printer. This particular report I am printing is 3 pages long. The printer prints 3 pages, however, only a small portion of each page is printed to the paper, and also it’s printed in a weird position. It prints the upper-left hand ¼ of the report in the upper-right hand ¼ of the page, and the rest of the paper is blank.

At first I think, “OK printer driver is messed up.” However, I can print from Word, Excel, and other programs just fine. Also, the report prints perfectly if I print a test version from the Crystal Reports report editor. So, it seems I’m missing some sort of setup command from inside of VB for the CRV or perhaps the crystal reports object itself. I just don’t have the foggiest idea what that command is.

Here is the function that sets up my Crystal Reports report, and then shows the report to the user.
Thanks in advance for your help.



Private Sub tlbStatSum_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tlbStatSum.ButtonClick

Dim fReport As New frmShowReport()

Dim selectionFormula As String

Dim intStore As Integer



Select Case tlbStatSum.Buttons.IndexOf(e.Button)

Case 0

fReport.crystalReport11.SetParameterValue("varstore", 1)

fReport.crystalReport11.SetParameterValue("varsummary", 1)

fReport.Text = "Inventory Profitability Analysis - Printable Statistics Summary"

Case 1

fReport.crystalReport11.SetParameterValue("varstore", 0)

fReport.crystalReport11.SetParameterValue("varsummary", 0)

fReport.Text = "Inventory Profitability Analysis - Detailed Report"

Case Else

Return

End Select

fIstat.txtVend.Text = fIstat.txtVend.Text.ToUpper

fIstat.txtCatno.Text = fIstat.txtCatno.Text.ToUpper



selectionFormula = vbNullString

With fReport

.CrystalReportViewer1.LogOnInfo(0).ConnectionInfo.Password = "MyPassword"

.crystalReport11.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape

.crystalReport11.SetParameterValue("vend", fIstat.txtVend.Text)

.crystalReport11.SetParameterValue("catno", fIstat.txtCatno.Text)

If fIstat.cmbStore.SelectedValue <> -1 Then

intStore = fIstat.cmbStore.SelectedValue

selectionFormula = "({COMMAND.STORE} = " & intStore & ")"

.crystalReport11.SetParameterValue("varstore", intStore)

End If

If fIstat.chkPrimItemSw.Checked = True Then

If selectionFormula <> vbNullString Then

selectionFormula = selectionFormula & " and "

End If

selectionFormula = selectionFormula & "({COMMAND.PRIMARY} = ""P"")"

End If

If fIstat.chkSpecSw.Checked = True Then

If selectionFormula <> vbNullString Then

selectionFormula = selectionFormula & " and "

End If

selectionFormula = selectionFormula & "({COMMAND.TYPE}<>""X"")"

End If

.CrystalReportViewer1.SelectionFormula = selectionFormula

.CrystalReportViewer1.ShowRefreshButton = False

.Show()

End With

End Sub
  #2  
Old 09-08-2003, 11:30 AM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default

[ednf]..[/ednf]
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Linking Crystal Reports to Access Database thru VB rviguru Database and Reporting 2 08-24-2003 07:49 AM
Creating reports dynamically using VB6 and crystal Report 8 jaya Database and Reporting 0 08-22-2003 05:58 AM
Crystal and VB just03 Database and Reporting 6 04-11-2003 11:06 AM
Calling crystal report from Vb Pavankumaru Database and Reporting 3 03-05-2003 12:15 PM
Refresh data from Crystal Reports report Nicole De Wel Database and Reporting 2 12-05-2002 07:53 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->