The redirects complicate it a bit; otherwise you could just use RaiseEvent.
But you could do something like this in the events class:
Then you could assign that class instance a form, you could call DoThing from within the class, then from redirects you could addCode:Private mForm As Form Public Sub SetForm(ByVal obj As Form) Set mForm = obj End Sub Public Function GetForm() As Form Set GetForm = mForm End Function Public Sub DoThing() mForm.eventmethod End Sub
Then both types of events would call Sub eventmethod on the specific form;Code:Sub CallFormMethod(oClass As clsFileEvents) Dim f As Form Set f = oClass.GetForm f.eventmethod End Sub
Code:Public Sub eventmethod() Debug.Print "called event" End Sub Private Sub Command1_Click() Dim c As clsFileEvents Set c = New clsFileEvents c.SetForm Form1 c.DoThing CallFormMethod c




Reply With Quote