Common method to call .rdlc report from your application

I would like to share code for calling any rdlc report. It is assumed that application has menus and after clicking on each menu,different rdlc report is called. I hope you will like this article.

Code is as follows:
Public Sub CallPrjreport(ByVal strReportEmbeddedResource As String, ByVal strReportPath As String, ByRef callform As Form)

Dim frm As New view
frm.ReportViewer1.LocalReport.ReportEmbeddedResource = strReportEmbeddedResource.ToString()
frm.ReportViewer1.LocalReport.ReportPath = strReportPath.ToString()
frm.MdiParent = callform
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "ErrorFound")
End Try
End Sub

Pseudo Code for each menu click :
Call CallPrjreport (full path of rdlc report for eg d:\project_folder\reports\emp.rdlc , report name for eg emp.rdlc , Me)

It calls CallPrjreport by required parameters and reports will be displayed under MDI form.
I am sending following parameters: ReportEmbeddedResource , Report path as well as form to set MDI.
This method will avoid repetition of code in every menu click. This method can be placed in common file such as Module1.vb


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: