OptionGroup.MouseMove event (Access)

The MouseMove event occurs when the user moves the mouse.

Syntax

expression.MouseMove (Button, Shift, X, Y)

expression A variable that represents an OptionGroup object.

Parameters

Name Required/Optional Data type Description
Button Required Integer The button that was pressed or released when the event was triggered. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:
  • 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 Required Integer 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:
  • 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 Required Single The x coordinate for the current location of the mouse pointer, in twips.
Y Required Single The y coordinate for the current location of the mouse pointer, in twips.

Remarks

The MouseMove event applies only to forms, form sections, and controls on a form, and not to controls on a report.

This event does not apply to a label attached to another control, such as the label for a text box. It applies 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.

To run a macro or event procedure when these events occur, set the OnMouseMove property to the name of the macro or to [Event Procedure].

The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

To respond to an event caused by moving the mouse, you use a MouseMove event.

To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

Example

The following example determines where the mouse is and whether the left mouse button and/or the Shift key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

Private Sub Detail_MouseMove(Button As Integer, _ 
     Shift As Integer, X As Single, Y As Single) 
    Dim intShiftDown As Integer, intLeftButton As Integer 
 
    Me!Coordinates.Caption = X & ", " & Y 
    ' Use bit masks to determine state of 
    ' SHIFT key and left button. 
    intShiftDown = Shift And acShiftMask 
    intLeftButton = Button And acLeftButton 
    ' Check that SHIFT key and left button  
    ' are both pressed. 
    If intShiftDown And intLeftButton > 0 Then 
        MsgBox "Shift key and left mouse button were pressed." 
    End If 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.