One of the problems I am experiencing when using a tab control is that the coding get un-manageable as every tabs code is in the same form. (Any other ideas?)

I have a number of existing forms that I would like to embed in the tab control. Obviousely these forms must be in a modeless format. I can successfully do this using the SetParent command (user32.dll) but the problem comes in when I try to shut my User_Control down from vb. The system crashes, and I think that the problem is that I am using modeless forms.

This code works well if I shut the user-control down from the app - but if I shut it down from vb it crashes. By making frmOnDisplay a modal form the crashing does not occur.

Private Sub UserControl_Terminate()
' 'Make sure that you have closed the displayed form
If lngParent > 0 Then
Unload frmOnDisplay
End If

'Disconnect connection
Set adCON_Maint = Nothing
End Sub

I would appreciate any help/suggestion.