ict-torquilclark
asked on
An error occurred creating the form. See Exception.InnerException for details. The error is: Operation is not allowed when the object is open.
I have been working on a v.net app for the last couple of days
i am now getting the following error when trying to interact with one of my forms
in this case all i am trying to do is use form1.show in a button click even and i get the error in the title
it has been working all day, what have i dont o break it?
i am now getting the following error when trying to interact with one of my forms
in this case all i am trying to do is use form1.show in a button click even and i get the error in the title
it has been working all day, what have i dont o break it?
Try using the Shown event instead of Load event of form.
A quick Google of that exception message suggests it's primarily database-related. What code do you have in the button's Click event handler, in the Form's Sub New(), and in any of the Form's startup events (e.g. Load, Activate, Shown)?
ASKER
this is the code on the button click event
'Gets EmployerRef and Passes to EmployerForm
Dim rs As New ADODB.Recordset
Dim sqlStr As String
rs.CursorLocation = ADODB.CursorLocationEnum.a dUseClient
sqlStr = "SELECT EmployerRef FROM Employers WHERE FullName = '" & listboxEmployers.Text & "'"
rs.Open(sqlStr, sqlCnn, ADODB.CursorTypeEnum.adOpe nStatic, ADODB.LockTypeEnum.adLockO ptimistic)
OpenEmployer.Text = listboxEmployers.Text
OpenEmployer.labelEmployer Name.Text = listboxEmployers.Text
OpenEmployer.Tag = rs.Fields("EmployerRef").V alue
OpenEmployer.Show()
rs.Close()
Me.Close()
'Gets EmployerRef and Passes to EmployerForm
Dim rs As New ADODB.Recordset
Dim sqlStr As String
rs.CursorLocation = ADODB.CursorLocationEnum.a
sqlStr = "SELECT EmployerRef FROM Employers WHERE FullName = '" & listboxEmployers.Text & "'"
rs.Open(sqlStr, sqlCnn, ADODB.CursorTypeEnum.adOpe
OpenEmployer.Text = listboxEmployers.Text
OpenEmployer.labelEmployer
OpenEmployer.Tag = rs.Fields("EmployerRef").V
OpenEmployer.Show()
rs.Close()
Me.Close()
ASKER
I have also tried commenting out all of the code in the openemployer load event and i still get the error
> OpenEmployer.labelEmployer Name.Text = listboxEmployers.T
The above seems to be the offending line. You are accessing a label on form before its created. Comment that line out and see how it goes.
The above seems to be the offending line. You are accessing a label on form before its created. Comment that line out and see how it goes.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Accept http:#a35783706 as your solution (I didn't really contribute anything).
ASKER
my answer was correct
These controls are not built yet as would cause an inner exception.
Example:
Public Class Form1
Private wd As Integer = panel1.Width
...