I am writing an app where I will need to pop up a form to allow the user to enter data and then pass back at least a portion of that data (an ID perhaps) to the calling form. I have not completely decided how I am going to handle the data portion of the equation but am leaning toward what I will describe below.

The form for client information will have all of the clients general info then has 3 data grids. One each for Addresses, contacts and attorneys. To add, let's say, an address a form would pop up and allow entry of address info upon closing the pop up the address grid would then need to be updated. The addition of the Address touches two tables the Address table and the ClientAddress Table additionally nothing is permanent until the main for saves changes. My thought on this is to add the info to the tables and delete the info from the tables if the form is closed without saving or the undo changes button is clicked. For that I would need the ID's that were created when the data in the pop up was entered. So esentially from a popup I need to pass back to the parent window a table name and ID for each effected table.

7 Years
Discussion Span
Last Post by nolesce

For something like this, I usually create a property on the child that will give the information to the outside world and create the childform with a variable parent form withevents variable or add a handler to the form close event.

Then, in the parent form, trap the form closing event of the child and use the sender object to pull the value from.

Child form side:

Private ChildThisVariable As returningInformation
'.... other stuff...
    Public Property ReturningInfo() As returningInformaiton
            Return ChildThisVariable
        End Get
        Private Set(ByVal value As returningInformaiton)
            ChildThisVariable = value
        End Set
    End Property


Friend WithEvents MyChildForm As frmInheritTransaction

    Sub ShowMyChildForm()
        MyChildForm = New frmInheritTransaction
    End Sub
'....other stuff....
    Private ParentThisVariable As returningInformation
    Private Sub MyChildForm_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyChildForm.Closing
        If TypeOf (sender) Is frmInheritTransaction Then
            ParentThisVariable = DirectCast(sender, frmInheritTransaction).ReturningInfo
        End If
    End Sub

Note:returningInformation is a place holder for the type you want to get back.

If you need any more examples let me know, HTH.


That did the trick. Now I just have to code out all the rest of the crap they want to do from one form. Wheeeeee! Thanks a bunch.

This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.