Hi MJ
thanks for your reply.
What we would like to happen is the user selects a database and opens a details form. This form dynamically loads a tab control and populates it with controls, depending on what is in the database i.e.
Tab1.New1("frmAudit", 0, 28, 239, 218)
For i = 1 To TotalTabs
Tab1.AddTabPage("Page " & i)
Next i
Tab1.BringToFront
For i = 1 To NumFields
AddLabel("frmAudit", LabelName, 5, 10,ControlWidth, LabelHeight, FieldNames(i))
tab1.AddControl(LabelName,TabNumber,0,TopPosition)
Control(LabelName).color = 253,185,16
Next
etc. (not always labels, coule be anything)
Then when the form is closed I would like to 'de-populate' the tab control or better still get rid of altogether so that when another database is selected and the details form is re-opened, a new tab control is created and populated with a different set of controls.
So in answer to your question, yes we would like to get rid of the tab every time the details form is closed, although we would be happy if we could get rid of the controls on it ready for next time.
However, 'Dispose' when closing the form stops us from using the Tab control again next time.
Removing the tabpage seems to work but when you attempt to add a control that was used once before (when a previous database is selected again) it says it's already been added and fails with an error.
I don't understand why when we call RemoveTabPage it doesn't remove the controls that were added to it earlier. Or why there isn't a RemoveControl method. That would be really useful!
It seems that if you add a tab control, then a tabpage and some controls they remain there for the duration of the program, which is not useful.