Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to print directly without viewing and with particular record
This line show all record

RptObject.PrintToPrinter(1, false, 0, 0)

What I have tried:

'RPTfrmCashReport.CrystalReportViewer1.ReportSource = InvoicePrint

RptObject.PrintToPrinter(1, false, 0, 0)
CrystalReportViewer1.SelectionFormula = "{Invoice_Master.Invoice_no} = '" & LblInvoiceno.Text & "'"
Posted
Updated 4-Jan-20 21:19pm
v3
Comments
Christian Graus 5-Jan-20 1:59am    
I can't make sense of this question. What is RptObject? What technologies are you using and should have tagged in your question? What happens when you try this code? What issues are you facing?
Computechsoft 5-Jan-20 2:32am    
sorry some typing mistake
I want to send Direct print on printer without viewing i am using this line "PrintToPrinter" but this line show all records how to define particular record in this line just like "Selection formula"
CrystalReportViewer1.ReportSource = InvoicePrint

InvoicePrint.PrintToPrinter(1, false, 0, 0)
CrystalReportViewer1.SelectionFormula = "{Invoice_Master.Invoice_no} = '" & LblInvoiceno.Text & "'"

1 solution

 
Share this answer
 
Comments
Computechsoft 5-Jan-20 2:48am    
Yes i am using CrystalReportViewer. My selection formula is work fine no problem in this. When i sending report direct on printer therefore i am using this line

InvoicePrint.PrintToPrinter(1, false, 0, 0)

This line show all records how to set particular record in this line just like selection formula under below line.

CrystalReportViewer1.SelectionFormula = "{Invoice_Master.Invoice_no} = '" & LblInvoiceno.Text & "'"
Wendelius 5-Jan-20 3:10am    
Not sure if I understand the situation correctly. Are you saying that filtering works correctly with print preview but does not work when printing directly?

If this is the case, at least one problem in your code example is that you first print and the filter is set after that. This should be vice versa.

Also as said in my original answer, if you haven't yet tried the ViewTimeSelectionFormula property, please do. It behaves differently than the SelectionFormula property.

If these do not help, a completely different approach could be to restrict the data in the data sourced. For example if the InvoicePrint is a data table, you could use a DataView to filter the data to contain only relevant records and pass the data from the view to the report. This approach might be easier than controlling the filters inside a report
Computechsoft 5-Jan-20 3:27am    
Yes i am saying? that filtering works correctly with print preview but does not work when printing directly?

Yes i have applied ViewTimeSelectionFormula but report showing not print directly
so please resolve this issue without preview direct send to printer.

Dim mySelectionFormula As String = "{Invoice_Master.Invoice_no} = '" & LblInvoiceno.Text & "'" CrystalReportViewer1.ViewTimeSelectionFormula = mySelectionFormula
Wendelius 5-Jan-20 4:07am    
You haven't posted the complete code you're using, but I take it that you're using ReportDocument directly? If this is correct, you should set ReportDocument.RecordSelectionFormula Property[^]

If this isn't correct, please post all relevant codes you use for printing.
Computechsoft 5-Jan-20 4:18am    
Dim ConnectionInfo As ConnectionInfo = New ConnectionInfo()
Dim CashReceipt As New ReportDocument()
CashReceipt.Load(Application.StartupPath & "\Reports\Sale Reports\CashReceipt.rpt")
Dim MyTables As Tables = CashReceipt.Database.Tables

For Each MyTable As CrystalDecisions.CrystalReports.Engine.Table In MyTables
Dim MyTableLogonInfo As TableLogOnInfo = MyTable.LogOnInfo
ConnectionInfo.ServerName = ".\SQLEXPRESS"
ConnectionInfo.DatabaseName = ""Admin
ConnectionInfo.UserID = "sa"
ConnectionInfo.Password = "admin"
ConnectionInfo.IntegratedSecurity = False
MyTableLogonInfo.ConnectionInfo = ConnectionInfo
MyTable.ApplyLogOnInfo(MyTableLogonInfo)
Next

RPTfrmCashReport.CrystalReportViewer1.ReportSource = CashReceipt

CashReceipt.PrintToPrinter(1, False, 0, 0)

Dim mySelectionFormula As String = "{Invoice_Master.Invoice_no} = '" & FrmSalebill.LblInvoiceno.Text & "'"
RPTfrmCashReport.CrystalReportViewer1.ViewTimeSelectionFormula = mySelectionFormula

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900