Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to print a report without showing report.
In my form I have a save button. While clicking the save button the database is updating after the report displays. I can only print the report if users click the print button in the report. Now I need to print the report without clicking the print button in the report.
Currently I'm using Visual Studio 2012 with VB.Net and I use the default report viewer provided by Microsoft. I don't know if this a right way to print or not, if there are any alternate solutions for this problem please let me know.

Code currently used for printing:
VB
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
   If MsgBox("need a Print ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
      Me.tblpurchaseTableAdapter.Fill(Me.DsPurchase.tblpurchase, NUD.Value)
      Me.tblpurchasesplitTableAdapter.Fill(Me.DsPurchase.tblpurchasesplit, NUD.Value)
      Me.RptVwr.RefreshReport()
      RptVwr.Show()
   End If
End Sub
Posted
Updated 6-Aug-14 2:29am
v2
Comments
Kschuler 5-Aug-14 14:07pm    
You want to print the report without click the print button? So when exactly is it supposed to print? What code are you currently using to print it?
Mufeed007 6-Aug-14 1:14am    
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If MsgBox("need a Print ?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
Me.tblpurchaseTableAdapter.Fill(Me.DsPurchase.tblpurchase, NUD.Value)
Me.tblpurchasesplitTableAdapter.Fill(Me.DsPurchase.tblpurchasesplit, NUD.Value)
Me.RptVwr.RefreshReport()
RptVwr.Show()
End If
End Sub
Mufeed007 6-Aug-14 1:14am    
i need to print while a button clicks

1 solution

If I understand correctly, you are currently just using the report viewer and it's print button. So now you want to print without first having to see the preview in the report viewer. This sounds like a pretty common request, you should probably have tried to search google[^] first.

Here is an MSDN article that I found in the google search that might be exactly what you are looking for:
Walkthrough: Printing a Local Report without Preview[^]
 
Share this answer
 
Comments
Mufeed007 7-Aug-14 2:57am    
is it works in vb.net application?
it uses console application. and xml database. in my project am using vb.net with mysql database
Kschuler 7-Aug-14 8:25am    
It should be very similar code. Start trying things and see what works. A lot of programming is trial and error.
Mufeed007 8-Aug-14 2:15am    
okie thanks for ua replay
Mufeed007 7-Aug-14 2:57am    
i dont want to preview the print. i just need to print the rdlc report

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