MouseUp Event [Access 2003 VBA Language Reference]
The MouseUp event occurs when the user releases a mouse button.
Private Sub object_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Object The name of a Form, Form section, or control on a Form.
Button The button that was pressed (MouseDown) or released (MouseUp) to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:
Constant Description
acLeftButton The bit mask for the left mouse button.
acRightButton The bit mask for the right mouse button.
acMiddleButton The bit mask for the middle mouse button.
Shift The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:
Constant Description
acShiftMask The bit mask for the SHIFT key.
acCtrlMask The bit mask for the CTRL key.
acAltMask The bit mask for the ALT key.
X, Y The x and y coordinates for the current location of the mouse pointer. The X and Y arguments are always expressed in twips.
Remarks
- The MouseUp events apply only to forms, form sections , and controls on a form, not controls on a report.
- These events don't apply to a label attached to another control, such as the label for a text box. They apply only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.
Remarks
To run a macro or event procedure when these events occur, set the OnMouseUp property to the name of the macro or to [Event Procedure].
You can use a MouseUp event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseUp 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 MouseUp event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseUp event for a form section to occur, press the mouse button in a blank area of the form section.
The following applies to MouseUp events:
- If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.
- If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.
To respond to an event caused by moving the mouse, you use a MouseMove event.
Macro
You can use a MouseDown or MouseUp macro to respond whenever the user presses or releases a mouse button in a form or control. However, macros can't return the button code and determine which mouse button was pressed, so you typically use event procedures with this event.
You can't use the CancelEvent action in a MouseDown or MouseUp macro, with one exception: You can use the CancelEvent action in a MouseDown macro to cancel the event that occurs when you press the right mouse button. For example, you can cancel the display of a shortcut menu and display your own custom shortcut menu.
Applies to | BoundObjectFrame Object | CheckBox Object | ComboBox Object | CommandButton Object | Form Object | Image Object | Label Object | ListBox Object | ObjectFrame Object | OptionButton Object | OptionGroup Object | Page Object | Rectangle Object | Section Object | TabControl Collection | TextBox Object | ToggleButton Object
See Also | MouseDown Event | OnMouseDown Property | OnMouseUp Property