Solved Focus on form open via VBA (1 Viewer)

GK in the UK

Registered User.
Local time
Today, 23:53
Joined
Dec 20, 2017
Messages
274
I have a login form which opens to the user name field which is what I want.

On login, it opens a menu form and closes itself.

When we log out, it opens the login form and the menu form hides.

But on subsequent opens the focus goes to the Access object list. I have to click in the user name field.

I tried this (SetFocus) in the menu form but focus still goes to the Access object pane:

Code:
Private Sub cmdLogout_Click()
  LogUserOut
  DoCmd.OpenForm (gstrFrmLogin)
  Forms(gstrFrmLogin).SetFocus
  Me.Visible = False    ' frm_menu (this form) is intended to never close, mSessionID is retained in here
  'DoCmd.Close acForm, Me.Name
End Sub

How can I get focus back to the opened form ?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 06:53
Joined
May 7, 2009
Messages
19,229
I think its a matter of re-arranging the code in your cmdlogout_click.
 

GK in the UK

Registered User.
Local time
Today, 23:53
Joined
Dec 20, 2017
Messages
274
Yes, it was that. .SetFocus after hiding. Thank you.
 

Users who are viewing this thread

Top Bottom