Results 1 to 7 of 7

Thread: [RESOLVED] Help with parameter for dlc report

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Resolved [RESOLVED] Help with parameter for dlc report

    I AM TRYING TO PASS A USER INPUTED VARABLE INTO A PARAMETER FOR THE REPORT BUT NO MATTER HOW I LOOK AT THIS AND THE DIFFERENT WAY I HAVE SEEN IT DONE ON THE WEB I CAN NOT GET IT TO WORK. MOST INSTANCES I HAVE FOUND ARE USING MSACCESS NOT SQL. SO THE PROBLEM IS UNKNOW TO ME.
    HERE IS THE CODE FROM MY REPORT VIEWER .vb PAGE

    I HAVE NAMED A PARAMETER IN THE REPORT AS WO
    Code:
    Imports Microsoft.Reporting.WinForms
    
    Public Class WorkOrderClose
        Private Sub WorkOrderClose_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim newPageSettings As New System.Drawing.Printing.PageSettings
            newPageSettings.Margins = New System.Drawing.Printing.Margins(35, 35, 35, 35)
            ReportViewer1.SetPageSettings(newPageSettings)
    
            'TODO: This line of code loads data into the 'HiTechDataSet.WorkOrders' table. You can move, or remove it, as needed.
            'Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet.WorkOrders)
    
            'Me.ReportViewer1.RefreshReport()
    
        End Sub
    
        Private Sub txtPrint_Click(sender As Object, e As EventArgs) Handles txtPrint.Click
            Dim WO As New ReportParameter("WO", txtBoxWO.Text)
    
            ' txtBoxWO.Text = TempVarPAGE WITH REPORT VIEWER ON
    
    
    THANKS
    
            Try
                Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet.WorkOrders)
                ReportViewer1.LocalReport.SetParameters(New ReportParameter("WO"))
                Me.ReportViewer1.RefreshReport()
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            End Try
        End Sub
    End Class
    WHEN I RUN THIS I GET THIS ERROR
    Name:  Untitled.jpg
Views: 643
Size:  17.1 KB

  2. #2
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Help with parameter for dlc report

    Please don't shout, and why not just tell us the error rather than posting an illegible screenshot?

    Kris

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Help with parameter for dlc report

    SORRY
    THE 'WO' parameter is missing a value

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: Help with parameter for dlc report

    Take a look at these two lines in your code:
    Code:
            Dim WO As New ReportParameter("WO", txtBoxWO.Text)
            ...
                ReportViewer1.LocalReport.SetParameters(New ReportParameter("WO"))
    The first line creates a ReportParameter, including a value, a stores it to a variable... which doesn't ever get used.

    The second line adds a ReportParameter to the report... but it creates a brand new one, without a value.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Help with parameter for dlc report

    I have been looking and reading and have made some additional changes.
    Code:
    Private Sub txtPrint_Click(sender As Object, e As EventArgs) Handles txtPrint.Click
            Dim WOID As New ReportParameter
            WOID.Name = "WOID"
            WOID.Values.Add(txtBoxWO.Text)
    
            Try
                Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet.WorkOrders)
                ReportViewer1.LocalReport.SetParameters(New ReportParameter() {WOID})
                Me.ReportViewer1.RefreshReport()
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            End Try
        End Sub
    Now no matter what I enter in the text box I show all items listed not just the one single record.
    When I look at the dataset.xsd file I see WorkOrderTableAdapters listed as-
    Fill,GetData()
    FillBY, GetDatBy(@WOID)

    How do I know it is using the fill by table adapter?

    Or do you see another problem to explore?
    Thanks

  6. #6
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: [RESOLVED] Help with parameter for dlc report

    Hi, I have some report questions that to this day has never been answered.. I have struggled with RDLC reports for many days and many hours....So I understand what frustration RDLC report can bring. I have learn a lot here from people at vbforums and hope to give back some day.

    You mark this question as resolved but you still have questions?

    Anyway, if I look what are asking then I think what you want to do is to input a value into a textbox in your report form (or perhaps even select a value from a combobox) and that value is a parameter for the report?

    This is how I do it and it takes me a very long time to figure this out.

    Add TableAdapter with relevant query. I see you already have done that. You want to display all work orders for the work order # that you type. Right?

    So you already have something like:

    Code:
    SELECT * 
    FROM WorkOrders
    WHERE (WorkOrderNumber = @WorkOrderNumber)
    If you run this query it will ask you to type the work order # and if you type the work order # it will display the relevant work orders.

    I can show you my example. I have a list of countries and regions. I want to on a report select a region and it must display all the countries in that region.

    STEP 1: Create Query:

    Code:
    SELECT ID, Country, Region, Population, Area, Density, CoastLine, NetMigration, InfantMortality, GDP, Literacy
    FROM tblCountryInformation
    WHERE (Region = @Region)
    SREP 2: Add new RDLC report

    In the RDLC report designer first add a "table" from the toolbox. It will ask you to specify DataSource and DataSet

    Attachment 168197

    Now design your report. Save report when done.

    Attachment 168199

    STEP 3: Add a Report Viewer to a user Form and select report that was created in STEP 2.

    Double click on user form and under Load event you will see the "original" fill:

    Code:
    Me.tblCountryInformationTableAdapter.Fill(Me.CountriesDataSet.tblCountryInformation)
    Me.ReportViewer1.RefreshReport()

    This is the report (without parameters)

    Attachment 168201

    But remember you created a query in STEP 1 for your parameter.

    On your form add a Combobox and Button (in my example I shall populate the combobox with Regions, but you use a textbox)

    In the button click event add your fill query(that was created in STEP 1). Now you will notice there is an error:

    Attachment 168203

    Simply do this:

    Attachment 168205

    Now your report will filter based on your parameter when you click the button.

  7. #7
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: [RESOLVED] Help with parameter for dlc report


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width