469,924 Members | 1,529 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,924 developers. It's quick & easy.

SetFocus to a form

I have a bunch of hidden, popup, non-modal forms.
Forms(myFormName).SetFocus makes myFormName visible.

However...

I have a bunch of non-hidden, popup, non-modal forms.
Forms(myFormName).SetFocus does not bring frmFormName to the front.

How can this be done?

lq

Nov 13 '05 #1
3 2519
On 16 Oct 2005 21:11:24 -0700, "Lauren Quantrell"
<la*************@hotmail.com> wrote:
I have a bunch of hidden, popup, non-modal forms.
Forms(myFormName).SetFocus makes myFormName visible.

However...

I have a bunch of non-hidden, popup, non-modal forms.
Forms(myFormName).SetFocus does not bring frmFormName to the front.

How can this be done?


Hide 'em first?

mike
Nov 13 '05 #2
I found the solution:

Private Declare Function apiSetForegroundWindow Lib "user32" Alias
"SetForegroundWindow" _
(ByVal hWnd As Long) As Long

Function BringFormToFront(F As Form)
On Error Resume Next
' bring a form to the front
Call apiSetForegroundWindow(F.hWnd)
End Function

Nov 13 '05 #3
The Function BringFormToFront works fine, except that was not the
problem.

Problem was I was clicking on a combo box of form names on another
form, so the focus was not leaving that form. When I moved the
....SetFocus code from the form to a code module it works fine.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Mad Scientist Jr | last post: by
3 posts views Thread by Jim Devenish | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.