"Gavin" <ga********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I would like to refresh a dataset on from 1 when form 2 closes.
How would I trap that event?
The Form's Closing Event is the one you're after, but it's only part
of the problem.
In Form 1, expose a Public method that will cause the DataSet to be
refreshed, as in :
Class Form1
. . .
Public Sub RefreshDataSet()
' Refresh DataSet
End Sub
When you instantiate Form2 (from Form 1, presumably) pass a
reference to the original Form. Many ways to do this, but a Public
property might be easiest, as in
Class Form2
. . .
Public WriteOnly Property CallingForm() As Form1
Set( Value as Form1 )
m_oCaller = Value
End Set
End Property
. . .
Private m_oCaller as Form1 = Nothing
then, back in Form1
Sub SomewhereInForm1()
Dim f as New Form2
f.CallingForm = Me
f.Show()
End Sub
In Form 2, handle the Closing Event and call the above method,
as in
Class Form2
. . .
Private Sub Form_Closing( _
ByVal sender as Object _
, ByVal e as System.ComponentModel.CancelEventArgs _
) Handles Form2.Closing
m_oCaller.RefreshDataSet()
End Sub
HTH,
Phill W.