PDA

View Full Version : The Form from Hell



MWE
02-22-2006, 06:28 PM
I am running Word2000.

I have a pretty simple userform. It has 5 checkboxes and 3 buttons. It communicates with the main application via a global boolean array of size [0 to 5]. The code to load and show the form from the main appl is ufrmRqmtMgmt_RemoveOptions.Show
The startup and shutdown code in the form's code module is Option Explicit

Private Sub UserForm_Activate()
RqmtIDRmvOpCode(0) = False
RqmtIDRmvOpCode(1) = False
RqmtIDRmvOpCode(2) = False
RqmtIDRmvOpCode(3) = False
RqmtIDRmvOpCode(4) = False
RqmtIDRmvOpCode(5) = False
Me.ckbxIDText = True
Me.ckbxMarkers = False
Me.ckbxBkMk = True
Me.ckbxTOR = True
Me.ckbxTOTBD = True
End Sub

Private Sub cmdbtnHelp_Click()

MsgBox "no help available yet"

End Sub

Private Sub cmdbtnCancel_Click()

RqmtIDRmvOpCode(0) = False
RqmtIDRmvOpCode(1) = False
RqmtIDRmvOpCode(2) = False
RqmtIDRmvOpCode(3) = False
RqmtIDRmvOpCode(4) = False
RqmtIDRmvOpCode(5) = False
Unload Me

End Sub

Private Sub cmdbtnOK_Click()

RqmtIDRmvOpCode(0) = True
RqmtIDRmvOpCode(1) = Me.ckbxIDText.Value
RqmtIDRmvOpCode(2) = Me.ckbxMarkers.Value
RqmtIDRmvOpCode(3) = Me.ckbxBkMk.Value
RqmtIDRmvOpCode(4) = Me.ckbxTOR.Value
RqmtIDRmvOpCode(5) = Me.ckbxTOTBD.Value
Unload Me

End Sub
The form loads and shows the way it should. The check boxes work as they should. The Help button and Cancel buttons do what they should, and the OK button passes correct information back to the main application. But when I click OK, the form does not close and unload. It stays around on the screen the next MsgBox display. :banghead:

Other forms in the same appl open and close fine.

Any ideas what might be wrong here?

Jacob Hilderbrand
02-22-2006, 07:20 PM
Is ScreenUpdating off?

MWE
02-22-2006, 07:26 PM
Is ScreenUpdating off?
ScreenUpdating is set to True.

matthewspatrick
02-22-2006, 07:42 PM
If you create a brand new form, recreate the controls, and paste in that code, do you get the same behavior?

MWE
02-22-2006, 07:47 PM
If you create a brand new form, recreate the controls, and paste in that code, do you get the same behavior?
That is the next step in trying to sort this out. However, if that works, I still do not know WHY the first attempt failed.

fumei
02-22-2006, 10:36 PM
May I ask why you are using UserForm_Activate, rather than UserForm_Initialize to set your....hmmmm, initial parameters?

MWE
02-23-2006, 11:00 AM
May I ask why you are using UserForm_Activate, rather than UserForm_Initialize to set your....hmmmm, initial parameters?
stupidity? I have typically used _Activate rather than _Initialize and never had a problem before. Now I know better.

MWE
02-23-2006, 11:04 AM
If you create a brand new form, recreate the controls, and paste in that code, do you get the same behavior?
I still have not tried this because the problem disappeared (maybe). When forms have been cranky in the past, I normally try a system restart and that fixes a large fraction of the problems. But that did not work here. However, after shutting down the system completely last night and restarting this AM, guess what ... the problem was gone the first few times I tested it. Then it returned.

Well, at least my problems are interesting :devil:

fumei
02-23-2006, 02:37 PM
If this is the case, then I think you have some memory leak problem. My guess is that somewhere, something is not being properly released. What else do you have happening? is it JUST this form?

MWE
02-23-2006, 03:51 PM
If this is the case, then I think you have some memory leak problem. My guess is that somewhere, something is not being properly released. What else do you have happening? is it JUST this form?
Hard to say exactly. This "project" has dozens of features that are new or at least somewhat new to me. My expertise in Word VBA was close to non-existent a few weeks ago, now I am dangerous.

I checked the procedural path that leads to the Form from Hell and there is nothing obvious that is not closing properly. However as per another thread (http://www.vbaexpress.com/forum/showthread.php?t=7181) (http://www.vbaexpress.com/forum/showthread.php?t=7181), there is a spurious copy of Excel floating around after the Word doc opens, and that may be contributing to the problem. Ironically, it was the funny behaviour of this form that started me checking what processes were running in the background and led to the other thread. I have learned some important things about what VBA does "implicitily" that have not (as best I know) ever been a problem previously.

Thanks for you help.