VBA UserForm Clicking Actual Frame of a "Frame" Doesn't Respond RRS feed

  • Question

  • I created a UserForm.  The form has several "frames" (for VB folks, VBA "frames" are called "groups" in VB for some reason).  I created a sub routine:

    Private Sub fraMyFrame_Click()
    End Sub

    If I click *inside* the frame then the click event is triggered and DoStuff runs.

    In a seemingly bizarre irony, if I click the actual frame itself (the caption or the border lines) it doesn't fire the event!!

    That makes NO sense.  How can it be that clicking the frame of a "Frame" doesn't trigger the Frame's click event??!!

    BTW, I have a sub routine for the UserForm_Click event, but clicking the Frame's actual frame doesn't fire that off either.

    Does anyone know of a work around to it?  


    Wednesday, September 18, 2013 2:16 AM

All replies

  • the mouse click,down and up events will not fire when the cursor is on the outer areas of the frame.

    if you report the x and y mouse position to the userforms caption you will see that top left of frame reports a negative position. once either x or y is zero or above the clicking events will fire.

    clicking the frame or even areas within it is not a normal way to trigger an event, is they are reason for this approach?

    maybe you could fake the frame by using labels.



    Wednesday, September 18, 2013 10:55 AM
  • I have a user form with 5 main frames.  There are rows of data within those frames in 3 columns.  If someone clicks on a data item inside a frame that row becomes bold.  

    If someone clicks on an area somewhere off the actual data, such as the userform itself or a blank area of the frame I want to turn the bold off.  I know in VB clicking on the frame itself (what is called a group in VB) fires the even, just the same as clicking an empty space inside the frame/group.  It makes no sense to me why that wouldn't work the same in VBA.  To be more exact, I certainly can understand if clicking the actual frame was different than click inside the frame, but what I don't understand is why clicking on the frame doesn't then have its own event.

    Why would anyone want clicking in the frame fire the frame click event, but clicking on the actual frame wouldn't?  Even if someone did want that, than it should be an option, not forced on us, as the other, (clicking the frame and inside the frame both fire the frame click event) is certainly the more logical.

    Saturday, September 21, 2013 1:32 PM