How to set several events to fire the same procedure?

  • Thread starter Thread starter Aldred@office
  • Start date Start date
A

Aldred@office

Hi,
I hope some one could help me in this. How could I have several different
events says mouse click and Enter to fire the same procedure?

Thanks.
 
On Tue, 3 Nov 2009 12:16:16 +0800, "Aldred@office" <aldred> wrote:

Very simple: create a private sub in your form's codebehind, and call
it from each event:
private sub SayHello()
Msgbox "Hi There!"
end sub

private sub myControl_MouseClick()
SayHello
end sub

private sub myControl_Enter()
SayHello
end sub

-Tom.
Microsoft Access MVP
 
Thank you so much.

Tom van Stiphout said:
On Tue, 3 Nov 2009 12:16:16 +0800, "Aldred@office" <aldred> wrote:

Very simple: create a private sub in your form's codebehind, and call
it from each event:
private sub SayHello()
Msgbox "Hi There!"
end sub

private sub myControl_MouseClick()
SayHello
end sub

private sub myControl_Enter()
SayHello
end sub

-Tom.
Microsoft Access MVP
 
Rather than creating the event in VBA, you can execute it directly from the
event by entering the call to the sub directly in the event text box of the
properties dialog for the control. The correct syntax would be:

=SayHello()
 
Back
Top