Detecting mouseclick anywhere on subform

miyu

New member
Local time
Today, 01:24
Joined
Oct 1, 2008
Messages
2
Thanks in advance for any answers or code snippets I receive. This seems like it would be pretty straightforward, but so far it hasn't worked out for me.

I have a bound subform and I would like it to "do something" when a user performs an action within it; the action could be grabbing the focus of controls within it, clicking within it, typing within it, etc.

Right now, starting out, I am now trying to detect clicks anywhere within it. I've tried the following code with mouse up, mouse down also, but no joy:

Code:
Private Sub Form_Click()
    MsgBox "Mouse"
End Sub
The function is attached to the subform itself, with the "On Click" event in the property sheet set to "[Event Procedure]".

The following doesn't seem to work either:

Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
    MsgBox "Key"
End Sub
If anyone knows what I am doing incorrectly please let me know. Thanks again for any input
 
What exactly are you trying to do, your post is rather vague. The form has an OnClick event, as does every section of the form and every textbox, combobox and label, and so forth, so you really have to set each of these items id you want some action carried out for each of these. Also, if your users tab thru the form (some users do, some don't) you'd have to take this into account and trap the GotFocus events for textboxes and such as well.
 
Unfortunately, sub-objects don't inherit events. A form is made up of several sections. Look at this:
Code:
Private Sub Detail_Click()
    MsgBox "Sub detail mouse"
End Sub
Private Sub Form_Click()
    MsgBox "Sub Form mouse"
End Sub
Private Sub ID_Click()
    MsgBox "Sub ID mouse"
End Sub

Now click along the outer edge of your form/subform (the record pointer or headers). Try using this code on a form and click on the form background.

Another way to say this is that Windows Messages don't get passed through the queue to containing objects in Access.

In short, you have to set the event handler for each individual object or sub-object.
 
To the repliers, thanks for helping a girl out.

Missingling, this is exactly what I want to do:
I have a bound subform and I would like it to "do something" when a user performs an action within it; the action could be grabbing the focus of controls within it, clicking within it, typing within it, etc.
I want something to execute when a user is interacting with a subform. So far, I haven't been able to even get the event to trigger on click (or on keypress for the matter,) using the code I cited above. In short, when I click anywhere on the subform, no message box.

George, thanks for the explanation. Now I know why it wasn't working! I'll just have to rethink my methods.
 

Users who are viewing this thread

Back
Top Bottom