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?
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?
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.
Nor have I.Why have both events for same control? I have never encountered this.
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
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
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.)
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.each of the 9 columns in the display will require individual MouseDown event procedures.
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
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.
. it does. Perhaps you need to use things like screen.activecontrolIt is from my attempts here that I concluded that Access does not support the the direct use of user functions in the MouseDown event
By "direct" I mean like pictured here:direct use of user functions in the MouseDown event
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?
Last edited by Micron; 05-17-2019 at 09:37 AM. Reason: spelin and gramur
The more we hear silence, the more we begin to think about our value in this universe.
Paraphrase of Professor Brian Cox.
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?"
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
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