Results 1 to 4 of 4
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    MouseDown doesn't fire

    I have a form with a MouseDown event. The form has option buttons where when one is selected with the Ctrl key also being down the form takes a different action. The event does not fire for some unknown reason. I added a msgbox to confirm. Any ideas as to why the event code does not fire.



    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '========================================================================================
    ' User wants to see the HELP file for selected option
    '========================================================================================
    If (Shift And acCtrlMask) Then
        MsgBox "Ctrl is down"
        bolHELP = True
    End If
    
    
    End Sub

  2. #2
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Do you not need to check for the correct value based on:

    Value Description
    1 SHIFT was pressed.
    2 CTRL was pressed.
    3 SHIFT and CTRL were pressed.
    4 ALT was pressed.
    5 ALT and SHIFT were pressed.
    6 ALT and CTRL were pressed.
    7 ALT, SHIFT, and CTRL were pressed.


    So you should be checking for

    If Shift = 3
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    Quote Originally Posted by GraeagleBill View Post
    I have a form with a MouseDown event. The form has option buttons where when one is selected with the Ctrl key also being down the form takes a different action. The event does not fire for some unknown reason. I added a msgbox to confirm. Any ideas as to why the event code does not fire.

    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '========================================================================================
    ' User wants to see the HELP file for selected option
    '========================================================================================
    If (Shift And acCtrlMask) Then
        MsgBox "Ctrl is down"
        bolHELP = True
    End If
    
    
    End Sub
    Have you looked at the MS pages?
    https://learn.microsoft.com/en-us/of...form.mousedown

    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '========================================================================================
    ' User wants to see the HELP file for selected option
    '========================================================================================
    If Button = acLeftButton Then MsgBox "Left is down"
     
    If Button = acRightButton Then MsgBox "Right is down"
    If Shift = 3 Then MsgBox "Shift & Ctrl"
    
    
    End Sub
    However I can only get it to fire if I click on the record indicator? Clicking anywhere on the form outside any control does nothing.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    However I can only get it to fire if I click on the record indicator? Clicking anywhere on the form outside any control does nothing.
    There's the problem! If Shift = 3 didn't fix the issue, as I had already tried that before the OP.

    The solution was to use the KeyDown event with the event properties Key Preview set to Yes. With that, bolHELP is set true and the ensuing form code responds accordingly.
    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    '========================================================================================
    ' User wants to see the HELP file for selected option
    '========================================================================================
    If KeyCode = 17 Then bolHELP = True
    
    
    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. OnPage event doesn't seem to fire
    By GraeagleBill in forum Reports
    Replies: 14
    Last Post: 09-11-2022, 01:20 PM
  2. Form_Current Doesn't Fire on First Record
    By RMittelman in forum Programming
    Replies: 6
    Last Post: 09-24-2019, 02:23 PM
  3. Form_Current doesn't fire when moving to first record.
    By MatthewGrace in forum Programming
    Replies: 14
    Last Post: 01-09-2019, 04:09 PM
  4. Replies: 2
    Last Post: 04-17-2017, 11:26 PM
  5. Replies: 5
    Last Post: 12-03-2013, 01:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums