getting source of event

  • Thread starter Thread starter Stephan Hagemann
  • Start date Start date
S

Stephan Hagemann

Hi,

I have multiple controls on a form that all raise the same OnClick Function
(since they have been generated automaticlly). In the Event procedure, how
can I find out which Object triggered the event?

Thanks
Stephan
 
Hi,


Screen.ActiveControl ? I know it is not totally safe, a preferable
approach would be


Private m_Who As Control ' form level declaration
....

Private Sub Toto_Click()
Set m_Who = Toto
MyOnClick( )
End Sub

Private Sub Tata_Click()
Set m_Who = Tata
MyOnClick( )
End Sub

Private Sub Titi_Click()
Set m_Who = Titi
MyOnClick( )
End Sub

.....

Private Sub MyOnClick()

If m_Who Is Nothing then exit sub
... 'do something
Set m_Who = Nothing

End Sub




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top