Mouse Clicks

way2bord

Registered User.
Local time
Yesterday, 21:44
Joined
Feb 8, 2013
Messages
177
I would like to update a txtbox with a simple int count of the number of times a mouse is left-clicked while on an active form.

How do I do this?
 
Create a custom function, lets call it LeftMouseClickCount()

Code:
Public Function LeftMouseClickCount()
Me.tbLeftClickCount = Val(Me.tbLeftClickCount) + 1
End Function

**Me.tbLeftClickCount is the name of the textbox to store the click count

Then for EVERY control on your form PLUS the different sections of the form (Header,Detail Footer etc) add =LeftMouseClickCount() to the On Click property.

Your count textbox wlll need to have a value in it when the forms opens (set the default to 0) or you will have an error.
 
I'm actually looking for info on mouse interactions via VBA, then tying that to a form.

You've given me events that are triggered off of objects - I'd like to trigger the event directly off the mouse click.

Let's alter the request slightly --

I would like to update a txtbox with a simple int count of the number of times a mouse is RIGHT-clicked while on an active form.
 
way2bord;1267269I would like to update a txtbox with a simple int count of the number of times a mouse is [U said:
RIGHT[/U]-clicked while on an active form.
Left or right?

No difference, whichever mouse button you want to capture you would have to do it off the back of the Click events. Access GUI is driven by events, interactions between the user and the GUI & its objects.

As far as i know there is no way to drive an event without interaction first.
 
Left or right?

No difference, whichever mouse button you want to capture you would have to do it off the back of the Click events. Access GUI is driven by events, interactions between the user and the GUI & its objects.

As far as i know there is no way to drive an event without interaction first.

I don't see an On Click event for Right Click - how do you capture it?

Is there code which could function based on the form window instead of individual components inside the form?

What about application window, instead of inside a form at all?
 
Search the Web for Windows Hooks. Not sure if there are click events in that, i know you can use it to capture mouse co-ords
 

Users who are viewing this thread

Back
Top Bottom