Solved

Fill Dataset from another form

Posted on 2008-06-24
3
241 Views
Last Modified: 2008-06-25
Hi Experts,

VS 2008,SQL 2005.

I have a form with a split container. The first panel has a tree control.On the 2nd panel I fill with a form at run time , If the first node is  clicked I load a customer form in the panel. If the 2nd node is clicked I load a Job form.I also have it check to see if the form that is needed on the 2nd panel is already loaded,if so I want to just update the data. I am trying to refill the dataset on the form in the 2nd panel but the following code id not working.

frmSubCustomer.FillCustomerDetail(SelectedCustomerID)    This is a sub on the frmSubCustomer


this is the code:

    Private Sub FillsubCustomerForm()
        Dim SubFrm As New frmSubCustomer

        SelectedCustomerID = Me.TreeCustomer.SelectedNode.Tag

        If Me.SplitContainer1.Panel2.Controls.Count > 0 Then
            If Me.SplitContainer1.Panel2.Controls(0).Name = "frmSubCustomer" Then
                frmSubCustomer.FillCustomerDetail(SelectedCustomerID)


            Else

                Me.SplitContainer1.Panel2.Controls.Clear()
                With SubFrm

                    .CurrentCustomerID = SelectedCustomerID
                    .TopLevel = False
                    .Dock = DockStyle.Fill
                    .WindowState = FormWindowState.Maximized
                    .Parent = Me
                    Me.SplitContainer1.Panel2.Controls.Add(SubFrm)
                    .Show()

                End With

            End If


Any help would be great. If you can think of a better way of doing this I wold like to see it as I am just starting to develop this App

Thank You
John
0
Comment
Question by:DjJohnny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
appari earned 500 total points
ID: 21861960
try this

 Private Sub FillsubCustomerForm()
        Dim SubFrm As object

        SelectedCustomerID = Me.TreeCustomer.SelectedNode.Tag

        If Me.SplitContainer1.Panel2.Controls.Count > 0 Then
            If Me.SplitContainer1.Panel2.Controls(0).Name = "frmSubCustomer" Then
            SubFrm = Me.SplitContainer1.Panel2.Controls(0)
                ctype(SubFrm, frmSubCustomer).FillCustomerDetail(SelectedCustomerID)


            Else

                Me.SplitContainer1.Panel2.Controls.Clear()
                With SubFrm

                    .CurrentCustomerID = SelectedCustomerID
                    .TopLevel = False
                    .Dock = DockStyle.Fill
                    .WindowState = FormWindowState.Maximized
                    .Parent = Me
                    Me.SplitContainer1.Panel2.Controls.Add(SubFrm)
                    .Show()

                End With

            End If

0
 
LVL 18

Expert Comment

by:philipjonathan
ID: 21862235
How far have you got? Are you handling the Tree's clicked event? You can handle the Tree's clicked event. If a click is detected, check if it's the 1st node or the 2nd one. Then check if the associated form is already loaded. If so, just refresh the data
0
 

Author Comment

by:DjJohnny
ID: 21864100
Thank You  appari and philipjonathan,

appari code worked. I see now that I need to create an object that I set as the form in the panel2. I was just trying to get to it directly.

John
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Find date of 2nd Thursday of each month 3 45
"lblTime is not declared" 3 65
vb.net code 9 28
Need Help With GDI+ in VB.Net 8 42
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question