The MouseDown event occurs when the user presses a mouse button.
To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].
You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.
To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.
The following apply to MouseDown events:
To respond to an event caused by moving the mouse, you use a MouseMove event.
The following example shows how you can find out which mouse button caused a MouseDown event.
To try the example, add the following event procedure to a form:
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, _
Y As Single)
If Button = acLeftButton Then
MsgBox "You pressed the left button."
End If
If Button = acRightButton Then
MsgBox "You pressed the right button."
End If
If Button = acMiddleButton Then
MsgBox "You pressed the middle button."
End If
End Sub