First I apologize for the long explanation here, if you don't wish to read through all of this explanation, skip to Problem: in bold text.

I wanted to explain everything just in case you needed more information, so I'm providing it now so I don't have to answer as many questions later.

Personal Information:
I am somewhat of a new programmer. I have been learning for over a year, doing research online, and reading a ton of books. I've come a long way and am now working as a programmer at my place of work, but by no means do I consider myself an advanced programmer.

I am developing an app that writes to an XML file and that's what I'm using to store information. This is just a test app that I'm building to increase my skills and knowledge.

Information:
I created a Subroutine that checks if a Form is being closed by pressing the X by the Maximize and Minimize buttons. If the Form is being closed by the user, then I need to know. The reason I need to know is that when a new department is being created (each department that's created must have an Admin Account associated with the Department so that changes can be made for each user that follows and is created for each department) I can then ask the user if they wish to cancel the creation of the department so that it can then be removed (the department has to be created before I can write the information to the XML, so the file has already been saved with the creation of the new department). So if they select Yes on the MessageBox then it calls to the Form that has the department information (department name is selected and I've greyed out the buttons and ListBox so no changes can be made and the department doesn't lose focus. I've also disabled the ability to close the Form by pressing the X or Exit button) to remove the Department and subtract (-1) from the NextUID Number in the XML file (this is how I generate Unique Identification Numbers for each Department and User Account being created.

I am using a FormClosing Subroutine to handle Booleans for the Forms that create the New Department and User Account. If they're open on the screen, I'm not allowing the Form that has the list of all departments to close. I'm doing this because in order to remove the New Department in the Event that the user doesn't wish to create an Admin Account I need to remove the New Department and I cannot do that if the Form that holds the list of all of the Departments is closed as I'm removing the account based on which department is selected on that Form. I cannot do that if the Form is accidentally or purposefully closed by the User who's logged in (Admin Rights).

Problem: When I add the Subroutine and try to look at the [Design] of the Form, I recieve an Error.

Error:

Instances of this error (1)

1. Hide Call Stack
at Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomEventBindingService.ValidateMethodN ame(String methodName)
at System.ComponentModel.Design.EventBindingService.EventPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAttachEventStatement(IDe signerSerializationManager manager, CodeAttachEventStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSeria lizationManager manager, CodeStatement statement)

Help with this error

MSDN Help

Forum posts about this error

Search the MSDN Forums for posts related to this error

It allows me to [Ignore & Continue], but then receive a MessageBox that says:

"[Microsoft Visual Studio] Ignoring these exceptions will put the designer in an unstable state that could result in the loss of controls. Do you want to continue?"

I selected No for now.

Can someone please take a look at my code and see if there's a better way o

Code:
Code:
    
    Private Sub DeptSelection(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing

        If e.CloseReason = CloseReason.UserClosing Then
            '--Need to notify DeptSelection.vb that form was closed without saving the creation of an Admin Account for the New Department that was just created
            
            If UserApplicationFormAtts.OpenStatus = True Or DeptEditInfo.OpenStatus = True Then
                e.Cancel = True
            Else
                e.Cancel = False
            End If
        End If

    End Sub
I thank everyone who can help me out and took the time to read this post.