Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

I kind of had the same problem you did. I had data bein cut off on the right and bottom sides. Even though it was all fine on the CRV. I finally fixed it by reducing the page margins of the report. Your case it sounds like you need to increase them.

 

I think the page margins may be your problem.

 

Let me know.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...