locked
vb northwind sql server database and report viewer RRS feed

  • Question

  • hi,

    "I want when user enter OrderId in Form1,  on 2nd  form report show the all records of orderDetail,  which belong to that OrderId"  

    Using Northwind database.

    Kindly Guide me.


    MUHAMMAD ANZAR E-mail : muhammadanzar@hotmail.com Mobile # :0092-3215096959

    Thursday, December 19, 2019 4:31 AM

All replies

  • "I want when user enter OrderId in Form1,  on 2nd  form report show the all records of orderDetail,  which belong to that OrderId"  

    The first form would have to send the id over to the second form using the second form's constructor.

    https://blogs.msmvps.com/deborahk/passing-data-between-forms-constructor/

    It's  a C# example, but  you should be able to figure it out.

    https://social.msdn.microsoft.com/Forums/en-US/9930f103-64b5-42d0-86c6-f011ec14dfd2/how-to-make-report-in-report-viewer-through-stored-procedure-in-windows-forms?forum=vsreportcontrols

    Thursday, December 19, 2019 10:22 PM
  • Hi muhammadanzar, 

    Thank you for posting here.

    As DA924x suggested, I make a test which pass data between two forms.

    Here’s the code and you can refer to it.

    Form1.

    Public Class Form1
        Public Property textBox1Text As String
            Get
                Return TextBox1.Text
            End Get
            Set(ByVal value As String)
                TextBox1.Text = value
            End Set
        End Property
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim frm As Form2 = New Form2(Me)
            frm.Show()
        End Sub
    End Class
    

    Form2.

    Public Class Form2
        Private mainForm As Form1 = Nothing
        Public Sub New(ByVal callingForm As Form)
            mainForm = TryCast(callingForm, Form1)
            InitializeComponent()
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TextBox1.Text = Me.mainForm.TextBox1.Text
        End Sub
    End Class
    

    Result of my test.

    Best Regards,

    Xingyu Zhao




    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.

    Monday, December 23, 2019 8:01 AM