Marshall Barton said:
Since that can not be done at runtime, I must assume that
you are using code just to make it easier for you to work in
design view. If that's the case, I will argue that it is
far easier to just select the specifc controls manally and
use the Format menu item, Bring to Front. You can select
multiple controls by holding down the Shift key as you click
on individual controls or drag a selection rectangle around
multiple controls.
If you really are hoping to do this at runtime, you'll
either have to give up on the idea or set the focus to the
appropriate control, which automatically displays it in
front of other controls.
Thanks for your reply.
I have nearly 500 Forms with thousands of buttons that I want to bring to
front so tooltips display correctly. I want to cycle trough all forms and
bring the all command buttons to front in VBA. Doing this manually will be a
VERY tedious task !!! Are you sure that there is no way to do this in code?
Code sample:look at comment: How can I make this work
Sub ResetFormsAnd Reports()
' Run this procedure once to reset all
' the sorting and filtering options on all
' your forms and reports.
Dim frm As Form
Dim rpt As Report
Dim obj As AccessObject
Dim ctl As Control
' Loop through all the forms:
For Each obj In CurrentProject.AllForms
DoCmd.OpenForm obj.Name, acDesign, , , , acHidden
Set frm = Forms(obj.Name)
frm.Filter = ""
frm.FilterOn = False
frm.OrderBy = ""
frm.OrderByOn = False
If frm.AllowDesignChanges = True Then
frm.AllowDesignChanges = False
End If
If frm.ViewsAllowed = 0 Then
frm.ViewsAllowed = 1
End If
For Each ctl In Forms(obj.Name).Controls
With ctl
Select Case .ControlType
Case acTextBox, acComboBox
.AllowAutoCorrect = False
'How can I make this work
Case acCommandButton
DoCmd.RunCommand acCmdBringToFront
End Select
End With
Next ctl
DoCmd.Close acForm, obj.Name, acSaveYes
Next obj
' Loop through all the reports:
For Each obj In CurrentProject.AllReports
DoCmd.OpenReport obj.Name, acDesign
Set rpt = Reports(obj.Name)
rpt.Filter = ""
rpt.FilterOn = False
rpt.OrderBy = ""
rpt.OrderByOn = False
DoCmd.Close acReport, obj.Name, acSaveYes
Next obj
End Sub