A way to send a frame backward on a userform

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
I can't get controls to appear over the top of a frame without actually inserting them into the frame. I can change the top and left properties so that the controls overlap the frame, but the frame is always in front.

Is it possible to get controls to appear in front of a frame?
 
Why use something for it's 'aestheticness' (new word) if it's not going to actually do the job?:)

What events are you having trouble with?
 
Upvote 0

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I didn’t notice that there was a second page to this thread. I don’t want my buttons floating in the form without any frame. It looks ugly. The frame looks great, but has some drawbacks (see below).
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
The event I’m having trouble with is the enter and the exit event on a textbox control. When the control receives focus from outside the frame, the event does not trigger. When the control receives focus from inside the frame, the event triggers.
<o:p> </o:p>
The same occurs in reverse with the exit event. That is, if the control loses focus to a control outside the frame, then the event does not trigger.. whereas if the control loses focus to a control inside the frame, then the event does trigger.
<o:p> </o:p>
I can easily reproduce this behavior by: 1) drawing a frame in a userform; 2) drawing a textbox inside the frame; 3) drawing a button inside the frame; 4) drawing a button outside the frame.
<o:p> </o:p>
Then adding this code to the userform object module:
<o:p> </o:p>
Code:
Private Sub TextBox1_Enter()<o:p></o:p>
<o:p> </o:p>
TextBox1 = "Hey"<o:p></o:p>
<o:p> </o:p>
End Sub
<o:p> </o:p>
The code triggers when the textbox takes focus from the framed button, but not when the textbox takes focus from the button outside the frame.
 
Upvote 0
So, create an image of the frame and use the image.

Also, I almost never use events associated with userform controls (other than click) because it is impossible to guarantee that the events will occur when you expect / want them to.

Because the Enter event on the text box I have inside the frame doesn't trigger when the text box takes focus from outside the frame. Only when the user tabs/clicks between controls within the frame do any Enter events attached to those controls successfully trigger.

But I like the way the frame looks on the form. So I want the textbox to overlap the frame.
 
Upvote 0
Yeah, I mentioned earlier in the thread that I was considering that. It seems like resource-overkill.

Can you think of another way to cause the following behavior?
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
When the user enters the textbox, if the textbox contains its default text, the default text automatically disappears. When the user exits the textbox, if the textbox contains an empty string, then the default text automatically reappears.
<o:p> </o:p>
It works great as long as the control takes focus from inside its container; eg, the frame or the form.
 
Upvote 0
I can't reproduce the error in Excel 2004 or 2011. Have you considered testing the Frame1.ActiveControl in the Frame's Enter event?
 
Upvote 0
Yeah, I mentioned earlier in the thread that I was considering that. It seems like resource-overkill.

Can you think of another way to cause the following behavior?
<o:p> </o:p>
When the user enters the textbox, if the textbox contains its default text, the default text automatically disappears. When the user exits the textbox, if the textbox contains an empty string, then the default text automatically reappears.
<o:p> </o:p>
It works great as long as the control takes focus from inside its container; eg, the frame or the form.

If you have only one textbox in the frame then you could try the following :

Code:
Private Const DefaultText As String = "BlaBla"

Private Sub Frame1_Enter()
    TextBox1.SetFocus
    Call ChangeText
End Sub

Private Sub Frame1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Call ChangeText
End Sub

Private Sub ChangeText()
    With TextBox1
        If .Text = DefaultText Then
            .Text = ""
        ElseIf .Text = "" Then
            .Text = DefaultText
        End If
    End With
End Sub
 
Upvote 0
I'm using '03 Pro, Mike. I can reproduce the issue every single time.

I don't know why I never considered using enter/exit events on both the frame and its controls. Doing that solved the problem.

Thanks guys.
 
Upvote 0

Forum statistics

Threads
1,225,156
Messages
6,183,230
Members
453,152
Latest member
ChrisMd

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top