How to set several events to fire the same procedure?

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.
 
T

Tom van Stiphout

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
 
A

Aldred@office

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
 
K

Klatuu

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top