I have a problem figuring out how to get from VB6 to VB.Net when it comes to Parent / Child Forms.
From what I can tell, I have to create the form and then create an instance of it.
This is what I have done:
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Dim Employees As New frmEmployees()
Employees.MdiParent = Me
Employees.Show()
End Sub
The form has 3 sql connections and several DataSets. The default connection strings are set for each sql data adapter.
When the child form loads the following sub is run:
Private Sub frmEmployees_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Loaded = False
Call LoadTables()
ComboBox1.SelectedIndex = 1
RadioButton1.Checked = True
Loaded = True
End Sub frmEmployees_Load
The first few lines of PRIVATE SUB LoadTables are:
Private Sub LoadTables()
DsEmployees1.Clear()
DsCopy21.Clear()
DsCopy31.Clear()
DsAllDeductions1.Clear()
DsAllEarnings1.Clear()
DsRegRep1.Clear()
DsRegRep21.Clear()
sdaFedMStatus.Fill(DsCopy21)
When I exit the Child form the following code is executed:
Private Sub frmEmployees_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Try
SqlConnection1.Close()
Catch
End Try
SqlConnection1.Dispose()
MsgBox(ChangedMain)
End Sub frmEmployees_Closing
HERES MY PROBLEM.
When I close the Child form and try to reaccess it from the Parent I get an error on the line "sdaFedMStatus.fill(DsCopy21). The error says:
The SelectCommand property has not been initiallized before calling "Fill
WHY DOES THIS ERROR HAPPEN ON THE SECOND CALL OF THE FORM AND NOT ON THE FIRST?
HOW DO I CORRECT THIS PROBLEM.
From what I can tell, I have to create the form and then create an instance of it.
This is what I have done:
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
Dim Employees As New frmEmployees()
Employees.MdiParent = Me
Employees.Show()
End Sub
The form has 3 sql connections and several DataSets. The default connection strings are set for each sql data adapter.
When the child form loads the following sub is run:
Private Sub frmEmployees_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Loaded = False
Call LoadTables()
ComboBox1.SelectedIndex = 1
RadioButton1.Checked = True
Loaded = True
End Sub frmEmployees_Load
The first few lines of PRIVATE SUB LoadTables are:
Private Sub LoadTables()
DsEmployees1.Clear()
DsCopy21.Clear()
DsCopy31.Clear()
DsAllDeductions1.Clear()
DsAllEarnings1.Clear()
DsRegRep1.Clear()
DsRegRep21.Clear()
sdaFedMStatus.Fill(DsCopy21)
When I exit the Child form the following code is executed:
Private Sub frmEmployees_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Try
SqlConnection1.Close()
Catch
End Try
SqlConnection1.Dispose()
MsgBox(ChangedMain)
End Sub frmEmployees_Closing
HERES MY PROBLEM.
When I close the Child form and try to reaccess it from the Parent I get an error on the line "sdaFedMStatus.fill(DsCopy21). The error says:
The SelectCommand property has not been initiallized before calling "Fill
WHY DOES THIS ERROR HAPPEN ON THE SECOND CALL OF THE FORM AND NOT ON THE FIRST?
HOW DO I CORRECT THIS PROBLEM.
