By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

SetFocus to a form

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.