I have a form with a datagrid on it called frmDataForm. A new instance of this form is created every time I press a button to get data and the data is stored away in the new datagrid on the new form. The form of the creation command is...
Dim frmDataForm As New DataGridForm
The subroutine stops after the data form is created.
I can run this routine from a button as many times as I want, giving many forms of data. There will be as many forms (complete with datagrid and data) as times I have pressed the button.
My question is how do I get a reference to each newly created form from outside the creating routine so that I can shut all forms down with one button push. Perhaps I can store them in a collection as they are created then delete them something like this...
Private Sub DeleteAllDatagrids_Click()
Dim GridForm As Form
For Each GridForm In DataFormCollection
Unload GridForm
Next DataGridForm
End Sub
If this is right, what do I actually put into the collection to enable this bit of code to work ?
Thanks.
Boggg1
![[bigglasses] [bigglasses] [bigglasses]](/data/assets/smilies/bigglasses.gif)
Dim frmDataForm As New DataGridForm
The subroutine stops after the data form is created.
I can run this routine from a button as many times as I want, giving many forms of data. There will be as many forms (complete with datagrid and data) as times I have pressed the button.
My question is how do I get a reference to each newly created form from outside the creating routine so that I can shut all forms down with one button push. Perhaps I can store them in a collection as they are created then delete them something like this...
Private Sub DeleteAllDatagrids_Click()
Dim GridForm As Form
For Each GridForm In DataFormCollection
Unload GridForm
Next DataGridForm
End Sub
If this is right, what do I actually put into the collection to enable this bit of code to work ?
Thanks.
Boggg1
![[bigglasses] [bigglasses] [bigglasses]](/data/assets/smilies/bigglasses.gif)