Results 1 to 4 of 4
  1. #1
    TOPSie is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Mar 2021
    Posts
    153

    Double click causing two click events

    I have seen other threads elsewhere but they didn't give me a satisfactory answer. I have seen this happen in other circumstances so I know it is a general issue, but I will describe the current situation.



    I have a form which has a largish subform containing rows from a query. The whole of each row is covered by a transparent command button. So clicking anywhere on the row activates the command's click event.
    This click event is the only code for the (sub)form and it simply calls another (modal) form.

    If the user actually does a double click, the first click opens the modal form and the second click seems to activate whatever control on the modal form that the mouse happens to be over.

    So in many cases an undesired event is called.

    Instead of cutting off the users fingers, I have tried several things to avoid this.

    Firstly I have also created the double click event in the calling (sub) form. Ideally this would simply call the click event code, but as a diagnostic I firstly did msgbox "Double clicked"
    I have never seen this message no matter how quickly I try and click.

    So I tried to trap the second click in the modal form. There is a text box at the bottom of this form and it appears below the bottom of the calling form (which is now behind), so the mouse will not be over this text box
    So in the Form_Load and the Form_Current events of the modal form I do a SetFocus on this text box (there is no code behind the text box) but I put in a diagnostic msgbox in its click event
    Again this message never appears.

    So I have tried everything I can think of to catch this second click - but despite everything - depending on the position of the mouse an undesired control fires its click event.

  2. #2
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,159
    I would have thought the easiest solution is to simply only open the modal form with the double click?

    Your problem is that where as a double click can't change into a triple click, an single click event must by definition fire before a double click, so your modal form code is already executing.
    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
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,425
    I dunno. The way I read it, the second click occurs on the modal form, so it is not a double click, it is 2 clicks in rapid succession. Maybe that's not correct.
    so the mouse will not be over this text box
    Giving focus to a control puts the insertion pointer in the control; it has no effect on where the mouse pointer is.
    I'd try putting break points in all the relevant events you had before you added all this other stuff and step through all of that. Then using it normally and with these rapid clicks (not sure you need the double click event on the command button at all), see if it's really executing code as you describe. You might find that something else is causing the behaviour.

    If that doesn't reveal anything, consider a module level variable that the first click sets. If it has a value, exit the click event. When the modal form closes, reset the variable. However, if the first button click opens a form that is truly modal then a second click should get ignored since the first form should not be able to initiate events until the modal form is closed. That's why I think you need to step through everything. Of course, if my interpretation is wrong (as I pointed out it may be) then it can't be a double click event doing this if you didn't have one to start with.

    Another option is for you to post a zipped copy of your db.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,742
    I like Minty's suggestion in post#2. Require a double click on the subform to open the modal form. Problem solved.

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

Similar Threads

  1. on click events not working.
    By Synergy.ron@gmail.com in forum Forms
    Replies: 1
    Last Post: 10-01-2021, 06:33 PM
  2. Replies: 6
    Last Post: 05-08-2019, 03:25 PM
  3. vba click events
    By bilalo in forum Programming
    Replies: 8
    Last Post: 01-31-2019, 02:35 PM
  4. Select ALL on Double Click
    By dweekley in forum Access
    Replies: 2
    Last Post: 05-08-2017, 10:27 AM
  5. On Double Click go to Subform
    By Theremin_Ohio in forum Access
    Replies: 2
    Last Post: 03-30-2011, 08:03 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
  •  
Other Forums: Microsoft Office Forums