SetFocus problem

R

RFraley

I have a userform with 3 textboxes (tbOldPassword, tbNewPassword1,
tbNewPassword2). when the userform is initialized NewPassword1 and
NewPassword2 have the enabled property set to false. In tbOldPassword the
afterupdate subroutine checks the value of what has been entered and then,
if appropriate, sets the enable property of tbNewPassword1 and
tbNewPassword2 to true. The problem is that focus should then (based on the
tabindex property) move to tbNewPassword1; it does not. Focus returns to
tbOldPassword and if I hit enter again, it will then move to tbNewPassword1.
I have tried to force focus to move to tbNewPassword1 by placing
"tbNewPassword1.setfocus" in the afterupdate subroutine following the
"tbNewPassword1.enabled = true" statement but that does not help. Any help
or ideas will be greatly appreciated.

If it helps here is the actual code:

Private Sub tbOldPassword_AfterUpdate()
If Sheets("veryhidden").Range("AdminPswd") = tbOldPassword Then
tbNewPassword1.Enabled = True
Label2.ForeColor = &H80000012
tbNewPassword2.Enabled = True
Label3.ForeColor = &H80000012
tbNewPassword1.SetFocus
Else
tbOldPassword = ""
End If
End Sub

Thanks,
Ralph Fraley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

AfterUpdate/BeforeUpdate and SetFocus 1
SetFocus Not working 4
SetFocus problem 7
SetFocus problem 3
Simple SetFocus on userform issue 7
Using SetFocus with Frames 2
Setfocus Problem 9
SetFocus question 2

Top