|
-
May 21st, 2020, 10:34 AM
#1
Thread Starter
Lively Member
Open a form from Form1 in "add record mode"
I am wanting to open an existing form in 'Add Record' mode from another form. In this case from my LoadInfo form - opening FuelInfo form.
I am using the following code that is not properly working - Can someone assist me please?
My original code opens the form by using the Menu1 as the Parent form then the child form (FuelInfo) opens. All forms are child of Menu1.
The commented out area (italicized) of the code works in opening the form but not in 'addnew' status, but it only works on the initial call. Any subsequent calls gives and error.
The embolden area is the new code I tried but does not work - it gives error 'There is no row at position 0' - . I suspect I am going to have to utilize the parent call I have commented out in some manner but unsure how to do it. Any suggestions?
Code:
Catch ex As Exception
If (LoadFormCount < 2) Then
MessageBox.Show(("Fuel Record for Load Number: " + tbPETSLoadNumber.Text + " does not exist.") & Environment.NewLine &
("Please create a record for Load Number: " + tbPETSLoadNumber.Text + " on the Fuel Form.") & Environment.NewLine + Environment.NewLine &
"You will now be re-directed to the FUEL Page to create the record.",
"Critical Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
My.Forms.FuelInfo.FuelTableBindingSource.AddNew()
'MenuForm.FuelData()
End If
LoadFormCount = 0
Return
End Try
Last edited by K3JAE; May 21st, 2020 at 10:44 AM.
-
May 22nd, 2020, 10:52 AM
#2
Thread Starter
Lively Member
Re: Open a form from Form1 in "add record mode"
... no one able to assist here?
-
May 22nd, 2020, 12:52 PM
#3
Re: Open a form from Form1 in "add record mode"
You're using some pretty non-standard terminology, and have an odd example, so it may be that nobody could quite understand what you meant. For example, I've been working in .NET for almost two decades, and my best guess for what this
I am wanting to open an existing form in 'Add Record' mode from another form.
means is that you are misunderstanding something about what forms are or how they work. I've never heard of 'Add Record' mode, and can't guess what that could mean to you.
You also show an exception catch statement, but not the Try block with the code that threw the exception in the first place. You have a variable with a reasonable name, but we have no idea what it means and what value it holds. After all the code you showed will do nothing at all under either of these scenarios:
1) No exception was thrown.
2) LoadFormCount >= 2.
Even if there IS an exception, and LoadFormCount is less than 2, all you appear to be doing is adding something to FuelInfo, but what you are adding doesn't look like it could possibly mean anything.
My usual boring signature: Nothing
 
-
May 22nd, 2020, 01:11 PM
#4
New Member
Re: Open a form from Form1 in "add record mode"
If form is already open, then code below works.
Code:
Dim frm As FuelInfo = My.Application.OpenForms.Item("FuelInfo")
FuelInfo.FuelTableBindingSource.AddNew()
-
May 22nd, 2020, 01:15 PM
#5
Thread Starter
Lively Member
Re: Open a form from Form1 in "add record mode"
 Originally Posted by Nyatiaju
If form is already open, then code below works.
Code:
Dim frm As FuelInfo = My.Application.OpenForms.Item("FuelInfo")
FuelInfo.FuelTableBindingSource.AddNew()
The form would not be already open when it is called.
-
May 22nd, 2020, 01:37 PM
#6
New Member
Re: Open a form from Form1 in "add record mode"
To Open New form with new record
Code:
Dim frm As New FuelInfo
frm.Show()
frm.TblFuelBindingSource.AddNew()
-
May 22nd, 2020, 02:25 PM
#7
Thread Starter
Lively Member
Re: Open a form from Form1 in "add record mode"
OK that works but does not resolve my initial request... it opens the form OUTSIDE of the MDI Parent. I need it to open as a child INSIDE the MDI Parent.
Last edited by K3JAE; May 22nd, 2020 at 02:42 PM.
Reason: corrected info
-
May 22nd, 2020, 03:27 PM
#8
Thread Starter
Lively Member
Re: Open a form from Form1 in "add record mode"
I have it resolved. Thanks for the help... the Info provided here got me on the correct path. Thanks again everyone.
Tags for this Thread
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
|