none
VS 2015 VB, How to pass variable into ReportViewer Header Textbox RRS feed

  • Question

  • Hello,

    I am new to VS 2015 VB programming.  I have created a Report using ReportViewer to display a database table.  I am trying to pass a string variable into the Report to be displayed.

    I have been looking a various web pages to help.  Most of the code shows setting parameters to pass the information.

    In VS 2015 Report (*.rdlc file) Properties does not allow creating Parameters.

    The Expressing property of the TextBox has a Parameter Category, but I do not know how to set.  

    Any help would be appreciated. in creating the VB code to pass the string into the Report TextBox in Visual Studio 2015 Visual Basic.

    Tuesday, May 23, 2017 11:35 AM

All replies

  • Hi Alanzan,

    According to your description, you would need to pass the report that variable as a parameter, then place the parameter field on the report.

     More detailed step, please refer to:

    http://visualbasic.ittoolbox.com/groups/technical-functional/visualbasic-l/passing-variable-value-to-reportviewer-in-vbnet-windows-form-3548401

    Hope it is helpful to you.

    Best Regards,

    Cherry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, May 24, 2017 3:10 AM
    Moderator
  • Cherry,

    As I stated I am using Visual Studio 2015 Prof on a Window 10 operating system.

    In the link you provided it states 'Place a Parameter field on the Report from the menu : Report >> ReportParameters >> Add >> give name as MyPar and Check AllowBlank Value, Select appropriate data type.'

    I would like to add screen shot, but account still has to be verified.

    The Report menu options are Report Properties..., View (Ruler, Grouping), Add Page Header, and Add Page Footer

    The Report Properties window  just has four options Page Setup, Code, References, and Variables.  There is no option to add Parameters.

    I did add the code to the Report Viewer form load event:
    With rv1MailDist
      .LocalReport = 'MailDist.rdlc'
      Dim lpar as New ReportParameter('MyPar', strMailDistMonYear)
      Dim lpar1(0) as ReportParameter
      lpar1(0) = lpar
      .localReport.SetParameter(lpar1)
    End With
    rv1MailDist.SetDisplayMode(DiplayMode.Normal)

    When the code hit the bolded line received the error "An error occurred during local report processing".

    Could have gotten the error because 'MyPar' Parameter could not be set on ReportViewer.

    Any other suggestions?

    Thanks,
    Alanzan



    • Edited by Alanzan Wednesday, May 24, 2017 10:04 AM
    Wednesday, May 24, 2017 10:03 AM
  • Hi Alanzan,

    According to your description, I'm not sure what is the issue, do you want to display datatable in your rdlc page, or pass parameter to your datatable for filter something?

    Best regards,

    Cole Wu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 9, 2017 5:48 AM
    Moderator
  • Cole,

    I trying to pass an string I type in a VB textbox to a textbox in the report header.

    Thanks for any support you can provide.

    Alanzan

    Saturday, June 10, 2017 11:28 PM