Results 1 to 13 of 13

OnClick ALSO firing when control is "double-clicked"

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

    OnClick ALSO firing when control is "double-clicked"

    I have a control that has both "Click" and "Double-Click" events coded. How do I sense the "double-click" within the "single-click" event when the user double-clicks the control so I can ignore the "single-click" event?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    47,301
    Nasty conundrum.

    I just tested this and Click event executes for both clicks of Double-Click.

    Why have both events for same control? I have never encountered this.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,258
    Why have both events for same control? I have never encountered this.
    Nor have I.

    The application is clicking on column headings. Single-click heading to control sorting and double-click to popup a search pane to search the column. I will abandon the double-click in favor of simply using the Alt key together with a single-click when the user wants to search the column. After all, it is an alternative use of the heading.......

    YIKES! So much for that idea. Access is using the Alt key for its own purpose, so trapping Alt keycode in the form's keydown event is not going to suffice here. Time for a nap

  4. #4
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    6,891
    or just use the mouse down event and use the button value to decide what to do

    Code:
    Private Sub myControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    select case button
         case acLedtButton
    
         case acRightButton
    
         case acMiddleButton
    
    end select
    
    End Sub

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,258
    Yes, a cleaner approach, left to sort, right to search. The only issue I have with this solution is that each of the 9 columns in the display will require individual MouseDown event procedures. I tried to create a common function but Access seems to have restrictions relating to automation objects that prevent that approach? (And yes, each of the procedures will act as "gates" to common code to handle the task(s) at hand.)

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    5,763
    each of the 9 columns in the display will require individual MouseDown event procedures.
    Not necessarily. For such cases I select all required controls in design view and for the desired event, enter the name of the function that is written to handle the event. Obviously you should have that function written first. So 1 function is assigned to one event for all 9 controls simultaneously. If concerned about which control was actually clicked then it's a bit more work if you're like me in that you wouldn't want to rely on Screen.ActiveControl. In that case, still 1 function, but the event call would have to be like = MyFunction(txtName) instead of just = MyFunction(). That means 9 edits to the call - one for each control. Still only one function though.
    - "doesn't work" is no help. Post err msgs and where.
    - Use code tags for code/sql. Implement changes in copies of your database.
    Sometimes I talk to myself - like when I need expert advice.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,258
    I tried exactly what you describe. However, in attempting to invoke a function like =CommonSearchRtn("LastName") as the object of the MouseDown Access complained definitively. I've done such approaches to common functionality repeatedly over the years but never to any of the mouse or key events. That's essentially what Ajax was suggesting in post #4. It is from my attempts here that I concluded that Access does not support the the direct use of user functions in the MouseDown event.

  8. #8
    Ajax is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    6,891
    It is from my attempts here that I concluded that Access does not support the the direct use of user functions in the MouseDown event
    . it does. Perhaps you need to use things like screen.activecontrol

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,258
    direct use of user functions in the MouseDown event
    By "direct" I mean like pictured here:Click image for larger version. 

Name:	000.jpg 
Views:	22 
Size:	22.3 KB 
ID:	38420

    Unless I'm missing something, Access will always create a procedure of the form "ControlName_MouseDown(Button As.......etc).

    Continuing with my efforts, apparently one can only test for the use of the Ctrl key in "Key Events", like KeyDown, NOT from an OnClick event?

  10. #10
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    5,763
    works for me. This is mousedown event, not click, in spite of what my little message might suggest.

    Click image for larger version. 

Name:	MD1.jpg 
Views:	19 
Size:	7.1 KB 
ID:	38422 Click image for larger version. 

Name:	md2.jpg 
Views:	18 
Size:	8.8 KB 
ID:	38423

    EDIT: Figured I should add prop sheet pic
    Click image for larger version. 

Name:	mdPropsheet.jpg 
Views:	18 
Size:	25.3 KB 
ID:	38424

    And no, it does not automatically create a default event. If it did, how could you have 2 events for the same action - a default one + yours?
    Last edited by Micron; 05-17-2019 at 09:37 AM. Reason: spelin and gramur
    - "doesn't work" is no help. Post err msgs and where.
    - Use code tags for code/sql. Implement changes in copies of your database.
    Sometimes I talk to myself - like when I need expert advice.

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,258
    I fear that I've muddied the water as it relates to the OP. Having abandoned the double-click idea in post #3, the issue became "How does one determine if the Ctrl key was held down when one holds down that key and clicks on a label control?"

  12. #12
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    5,763
    AFAIK, labels don't have any events?
    Wait, I guess you mean unattached labels! Then there are at least 5 shift values associated with mousedown. I think ctl is 2.
    Last edited by Micron; 05-17-2019 at 12:47 PM. Reason: added info

  13. #13
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,258
    The MouseDown Event sets "Shift" to 2 if the Ctl key is pressed with the mouse down. The Button parameter is not affected by the use of the Ctl key. I will populate each of the label controls with MouseDown event and call common code to handle the intended action.

    As always, thanks to everyone,
    Bill

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

Similar Threads

  1. Replies: 3
    Last Post: 02-13-2019, 01:49 AM
  2. Replies: 7
    Last Post: 11-30-2013, 12:33 PM
  3. Replies: 4
    Last Post: 10-08-2013, 02:42 AM
  4. Replies: 2
    Last Post: 10-01-2012, 06:47 PM
  5. Replies: 0
    Last Post: 12-06-2011, 11:01 AM

Posting Permissions

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