How to bring shown frame control to the top

Magic Polygon

New Member
Joined
Aug 20, 2023
Messages
30
Office Version
  1. 2019
Platform
  1. Windows
I have a Calendar Frame containing some controls, and I have a ListBox. The Calendar is initially invisible, until a button that toggles its visibility is clicked. When the Calendar appears, it appears below the ListBox instead of above. I tried to fix this by selecting the Calendar, then selecting Bring to Front on the Format menu, and then selecting the ListBox, then selecting Send to Back. This only brought the Calendar to the front in the VBE before running the code.

1693876351648.png
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Please provide your VBA code User Form or worksheet that contains these controls.
 
Upvote 0
maybe something along the lines of
VBA Code:
    With Me.DatePickerFrame
        .ZOrder (0)
        .Visible = True
    End With
 
Upvote 0
maybe something along the lines of
VBA Code:
    With Me.DatePickerFrame
        .ZOrder (0)
        .Visible = True
    End With
This produces a weird overlap effect when toggling the Calendar Frame. This is when the Calendar Frame is toggled on:

1693931028701.png


and this is when the Calendar Frame is toggled off:

1693931294567.png
 
Upvote 0
Why don't you just toggle the .Visible property for both the DatePicker frame and the SearchResultsListBox.

Something like:
VBA Code:
    DatePickerFrame.Visible = Not DatePickerFrame.Visible
    SearchResultsListBox.Visible = Not DatePickerFrame.Visible
 
Upvote 1
Why don't you just toggle the .Visible property for both the DatePicker frame and the SearchResultsListBox.

Something like:
VBA Code:
    DatePickerFrame.Visible = Not DatePickerFrame.Visible
    SearchResultsListBox.Visible = Not DatePickerFrame.Visible
Yep, that's much better than what I had at first.
 
Upvote 0
Yep, that's much better than what I had at first.
Here's my modified code toggle both.
VBA Code:
Public Sub ToggleDatePicker(DateTextBox As Control)
    
    'check if its visible
    'toggle calendar
    DatePickerFrame.Visible = Not DatePickerFrame.Visible
    'toggle listbox
    SearchResultsListBox.Visible = Not DatePickerFrame.Visible
        
    If Me.Controls("DatePickerFrame").Visible Then
        
        'set the global control so when the calendar gets clicked
        'we know what textbox to update
        Set DateControl = DateTextBox
        
        'set the position of the calendar
        With Me.DatePickerFrame
          .Top = DateControl.Top + 40
          .Left = DateControl.Left + DateControl.Width - .Width
        
        End With
    End If
 
Upvote 0
@Magic Polygon

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,215,084
Messages
6,123,029
Members
449,092
Latest member
ikke

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