|
-
July 9th, 2009, 07:23 AM
#1
MDI Application Help
Hi All
I have an Application with 2 forms
Form 1 = FrmWindow this is an MdiParent Form
Form 2 = FrmInput this is an MdiChild Form
On Form 1 I have a Menu thats says New Input the onclick event looks as follows.
Code:
Dim ChildForm As Form
ChildForm = My.Forms.FrmInput
ChildForm.MdiParent = Me
ChildForm.Show()
This works and opens the FrmInput as a child of FrmWindow.
On the form FrmInput I have two Textbox Controls and 2 Button Controls
Textbox 1 = TxtName
Textbox 2 = TxtEmail
Button 1 = BtnSave
Button 2 = BtnExit
On the On Click event of BtnSave I have
The Public Sub for SaveInformation Looks like this.
Code:
Public Sub SaveInformation()
Dim con As New SqlClient.SqlConnection()
Dim com As New SqlClient.SqlCommand
con.ConnectionString = SQLConnection()
con.Open()
com.Connection = con
com.CommandText = "INSERT INTO TblInformation(Name,Email_Address) VALUES(@Name,@Email_Address)"
com.Parameters.AddWithValue("@Name", My.Forms.FrmInput.TxtName.Text)
com.Parameters.AddWithValue("@Email_Address", My.Forms.FrmInput.TxtEmail.Text)
com.ExecuteNonQuery()
con.Dispose()
com.Dispose()
End Sub
So when you click the save button it inserts a new record into the table TblInformation on my SQL database, everything works great. Now my problem is I want to be able to open multiple instances of the form FrmInput at the same time.
So I changed the New Input button to the following
Code:
Dim ChildForm As Form
Dim ChildInstance As New FrmInput
ChildForm = ChildInstance
ChildForm.MdiParent = Me
ChildForm.Show()
This works and I can now open up mutiple instances of the form FrmInput, what I cant figure out is how to save the information on a particular instance.
Any and all help is apprecited.
Cheers
Djbell
-
July 9th, 2009, 09:53 AM
#2
Re: MDI Application Help
Where are you calling the save routine from?
-
July 9th, 2009, 10:19 AM
#3
Re: MDI Application Help
Hi DataMiser
I am calling the save routine from a Module I have created specifically for Data Functions
Cheers
Djbell
-
July 9th, 2009, 09:23 PM
#4
Re: MDI Application Help
The code can be in a module or class but should be called from the instance of the form in question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|