none
My.settings and reports

    Question

  • Hi all,

    At this moment I'm busy with reporting. I'm using rdlc reports. I know how to use the report wizard and the designer. One question, I can't find anything on the forums about this. In my application I have a settings file (my.settings), with a lot of data stored in it. I have some fields like Company_Name, Street, Number, Zip_Code etc. I want to create a report header showing the values from those fields. But I absolutely don't know how to access those fields within my report.

    Any suggestions?

    Regards,

    Mark

    Friday, March 10, 2017 11:09 AM

Answers

  • If you know the settings name is simply something like:

    ' If it's a String...
    Dim YourField1 as string = My.Settings.Company_Name

    • Proposed as answer by tommytwotrain Friday, April 21, 2017 12:59 PM
    • Marked as answer by Mark Hofland Friday, April 21, 2017 1:29 PM
    Friday, March 10, 2017 11:15 AM
  • Hi Cyrille,

    I figured out how it works for me.

    In Report Designer, add some parameters. And the code to fill them looks like this:

    Dim Bdr_Naam As New ReportParameter("Bdr_Naam", My.Settings.Bdr_Naam)
            Dim Bdr_Straat As New ReportParameter("Bdr_Straat", My.Settings.Bdr_Straat)
            Dim Bdr_Postc As New ReportParameter("Bdr_Postc", My.Settings.Bdr_Postc)
            Dim Bdr_Plaats As New ReportParameter("Bdr_Plaats", My.Settings.Bdr_Plaats)
            Dim Bdr_Tel As New ReportParameter("Bdr_Tel", My.Settings.Bdr_Tel)
            Dim Eenh_Vis As New ReportParameter("Eenh_Vis", CheckBox1.Checked)
    
    Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Naam})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Straat})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Postc})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Plaats})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Tel})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Eenh_Vis})
    
            Me.ReportViewer1.RefreshReport()

    This works for me.

    regards,

    Mark

    • Marked as answer by Mark Hofland Friday, April 21, 2017 1:29 PM
    Friday, April 21, 2017 10:15 AM

All replies

  • If you know the settings name is simply something like:

    ' If it's a String...
    Dim YourField1 as string = My.Settings.Company_Name

    • Proposed as answer by tommytwotrain Friday, April 21, 2017 12:59 PM
    • Marked as answer by Mark Hofland Friday, April 21, 2017 1:29 PM
    Friday, March 10, 2017 11:15 AM
  • Hi Cyrille,

    I figured out how it works for me.

    In Report Designer, add some parameters. And the code to fill them looks like this:

    Dim Bdr_Naam As New ReportParameter("Bdr_Naam", My.Settings.Bdr_Naam)
            Dim Bdr_Straat As New ReportParameter("Bdr_Straat", My.Settings.Bdr_Straat)
            Dim Bdr_Postc As New ReportParameter("Bdr_Postc", My.Settings.Bdr_Postc)
            Dim Bdr_Plaats As New ReportParameter("Bdr_Plaats", My.Settings.Bdr_Plaats)
            Dim Bdr_Tel As New ReportParameter("Bdr_Tel", My.Settings.Bdr_Tel)
            Dim Eenh_Vis As New ReportParameter("Eenh_Vis", CheckBox1.Checked)
    
    Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Naam})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Straat})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Postc})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Plaats})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Bdr_Tel})
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {Eenh_Vis})
    
            Me.ReportViewer1.RefreshReport()

    This works for me.

    regards,

    Mark

    • Marked as answer by Mark Hofland Friday, April 21, 2017 1:29 PM
    Friday, April 21, 2017 10:15 AM
  • Great!

    If post helped mark it as answer to close the Thread.

    Thanks

    Friday, April 21, 2017 10:22 AM
  • I Did,

    Thanks

    Regards,

    Mark

    Friday, April 21, 2017 1:30 PM