Results 1 to 8 of 8
  1. #1
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111

    Long Click Event Possible?

    I'd like to have code trigger if a user clicks a button for an extended period of time, i.e. they hold left click on a button for ~3 seconds. I've done a bit of research on this and found the "Form.TimerInterval" property, and the "Form_Timer" event, but that just triggers ever X seconds based on what the TimerInterval is set to. Is there a way to use that to accomplish what I'm trying to do? Is it possible to time how long a button has been pressed down for?




    From what I found through my searching it seems to be possible, I've just never done anything with timers in access so I'm not sure what the best way to go about it would be.

    As always, any help is appreciated!

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    The only way you could achieve that would be in the Mouse Down event https://msdn.microsoft.com/en-us/vba...or=-2147217396
    You would have to save the time it was pressed (in a form level variable) , then in the MouseUp event check the length of time elapsed and if appropriate fire your event.

    I personally would probably avoid doing this, as I suspect it will make all other mouse driven events very flakey.
    Add another button or a right click menu for "special" actions.
    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
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111
    I looked into setting up a right click menu as you suggested, but from what I saw it requires a reference to the Microsoft Office Object Library, which I do not have and cannot get at work. Is there another way of doing this or am I stuck using the mouseDown/Up events?

  4. #4
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    If you have Access installed you will have that reference library installed as well.
    Pretty certain that its a default of any Office install..
    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 ↓↓

  5. #5
    ItsRoland is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Posts
    111
    The example code I found was using "Dim combo As CommnadBarComboBox", which gives the error "User-defined type not defined". Not sure if that means I don't have the reference I need or not, I've never messed with this kind of thing before.

  6. #6
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,144
    You don't need that to create a right click menu.
    I haven't got the code to hand but it can be achieved without any external reference as far as I can remember.

    Have a google for Access shortcut menu's
    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 ↓↓

  7. #7
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    There is no "long click" type of event for a control itself.
    I think a mousedown event on a form will only apply to the form on which the code resides and won't affect any mouse clicks anywhere else. You'd get the system time at the point of the mouse click, loop until you arrive at the new time (start time + specified interval) and at the end of the interval, check if the button is still depressed. This would require diverting to another function (not sub) that returns the mouse button state value. So a lot of code for what seems like a weird goal, and upon every mouse click on the subject control(s), you would not be able to do anything until after the function runs, which is after the loop finishes. Why would you care if I, as a user, held a mouse button down for several seconds, especially if you're going to force user to move off the control to respond to a prompt.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,850
    Roland,

    Can you tell us in business terms (plain English) why you want to do this?

    For example, if you had a button and when clicked it invoked some code --what difference exists between a "normal" button click and a long click button you envisage? I'm not seeing the need, but I (and readers) do not know the details of your requirement.

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

Similar Threads

  1. Replies: 2
    Last Post: 10-09-2016, 05:41 PM
  2. Need help with click Event
    By DXXPublic in forum Programming
    Replies: 3
    Last Post: 09-23-2015, 06:55 PM
  3. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  4. On Click Event with a combo box
    By PRHoff in forum Forms
    Replies: 4
    Last Post: 02-27-2015, 06:18 PM
  5. On Click Event Procedure
    By MrDean in forum Forms
    Replies: 3
    Last Post: 10-07-2009, 07:16 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