Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > .NET 3.5 and Visual Studio. 2008 > Visual Studio 2008
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Visual Studio 2008 For discussing Visual Studio 2008. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2008 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 23rd, 2012, 09:09 AM
Registered User
Points: 40, Level: 1
Points: 40, Level: 1 Points: 40, Level: 1 Points: 40, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing data between forms

I'm pretty new to to Visual Studio and have hit a problem.I have a number of forms in an app, the parent form holds information about invoice queries. On the main form I have buttons that open another form showing further detail on the query. I need to pass 3 pieces of info (Query, Zdocref & Invoicenum) which are in a toolstrip, from the first form to the second and then have the second form show the relevant data. The forms are based on stored procedures which I know work, but I can only get 2 of the pieces of info to pass to the second form, below is the code for the 2 forms, any help would be appreciated as it's driving me mad. I know it's going to be something simple.
Parent form
Code:
Public Class frmQuery
    Private Sub FillToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FillToolStripButton.Click
        Try
            Me.GetAdjByQueryTableAdapter.Fill(Me.HP3000_HansonDataSet.GetAdjByQuery, QueryNumToolStripTextBox.Text, Me.CompanyNo)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub frmQuery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.ZDocRefTextBox.Visible = False
    End Sub

    Private Sub btnAuth_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAuth.Click
        Dim frmAuth As New frmAjAuthInfo
        frmAuth.Query = Me.QueryNumToolStripTextBox.Text
        frmAuth.ZDocRef = Me.ZDocRefTextBox.Text
        frmAuth.InvoiceNum = Me.InvoiceNumTextBox.Text
        frmAuth.CompanyNo = Me.CompanyNo
        frmAuth.QueryToolStripTextBox.Text = frmAuth.Query
        frmAuth.TicketToolStripTextBox.Text = Me.ZDocRefTextBox.Text
        frmAuth.Show(Me.CompanyNo)
    End Sub

    Private Sub btnTktInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTktInfo.Click
        Dim frmTkt As New frmAjTktInfo
        frmTkt.Query = Me.QueryNumToolStripTextBox.Text
        frmTkt.ZDocRef = Me.ZDocRefTextBox.Text
        frmTkt.InvoiceNum = Me.InvoiceNumTextBox.Text
        frmTkt.CompanyNo = Me.CompanyNo
        frmTkt.QueryToolStripTextBox.Text = frmTkt.Query
        frmTkt.TicketToolStripTextBox.Text = Me.ZDocRefTextBox.Text
        frmTkt.InvoiceNumToolStripTextBox.Text = Me.InvoiceNumTextBox.Text
        frmTkt.Show(Me.CompanyNo)
    End Sub
End Class
Child form
Code:
Public Class frmAjTktInfo
    Private m_Query As String
    Private m_ZDocRef As String
    Private m_InvoiceNum As String

    Public Property Query() As String
        Get
            Return m_Query
        End Get
        Set(ByVal value As String)
            m_Query = value
        End Set
    End Property
    Public Property ZDocRef() As String
        Get
            Return m_ZDocRef
        End Get
        Set(ByVal value As String)
            m_ZDocRef = value
        End Set
    End Property
    Public Property InvoiceNum() As String
        Get
            Return m_InvoiceNum
        End Get
        Set(ByVal value As String)
            m_InvoiceNum = value
        End Set
    End Property

    Private Sub FillToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            Me.GetAjTktInfoTableAdapter.Fill(Me.HP3000_HansonDataSet.GetAjTktInfo, Me.CompanyNo, QueryToolStripTextBox.Text, TicketToolStripTextBox.Text, InvoiceNumToolStripTextBox.Text)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try

    End Sub
    Private Sub frmAjTktInfo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Me.GetAjTktInfoTableAdapter.Fill(Me.HP3000_HansonDataSet.GetAjTktInfo, Me.CompanyNo, Me.Query, Me.ZDocRef, Me.InvoiceNum)
        Catch ex As System.Exception
            System.Windows.Forms.MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub AjoAcnoLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub
End Class

Last edited by rongrace; November 23rd, 2012 at 09:49 AM.
Reply With Quote
  #2 (permalink)  
Old December 20th, 2012, 05:19 PM
Registered User
Points: 6, Level: 1
Points: 6, Level: 1 Points: 6, Level: 1 Points: 6, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try this:

Code:
Dim oForms as FormCollection
oForms = System.Windows.Forms.Application.OpenForms
is not the most genius solution, but at least you will be able to get the form object from any forms. You could then pass the value between the form.

Not Elegant, but it will work.
Reply With Quote
  #3 (permalink)  
Old December 22nd, 2012, 03:25 AM
Registered User
Points: 40, Level: 1
Points: 40, Level: 1 Points: 40, Level: 1 Points: 40, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2012
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I ended up doing something similar

Code:
    Private Sub btnTktInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTktInfo.Click
        Dim frmTkt As New frmAjTktInfo
        frmTkt.Query = Me.QueryNumToolStripTextBox.Text
        frmTkt.ZDocRef = Me.ZDocRefTextBox.Text
        frmTkt.InvoiceNum = Me.InvoiceNumTextBox.Text
        frmTkt.CompanyNo = Me.CompanyNo
        frmTkt.QueryToolStripTextBox.Text = frmTkt.Query
        frmTkt.TicketToolStripTextBox.Text = frmTkt.ZDocRef
        frmTkt.InvoiceNumToolStripTextBox.Text = frmTkt.InvoiceNum
        frmTkt.Show(Me.CompanyNo)
    End Sub
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 3.5 - Passing data to ASPX pages via forms? stephen_mc ASP.NET 3.5 Basics 1 June 17th, 2010 10:10 AM
passing data on multiple forms dzisaacs C# 2 December 6th, 2007 02:03 PM
Passing data between forms pactite Access 5 June 4th, 2005 04:02 PM
Passing data between forms rwalker VS.NET 2002/2003 6 February 17th, 2005 08:17 AM



All times are GMT -4. The time now is 06:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.