ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SetFocus problem (https://www.excelbanter.com/excel-programming/276187-setfocus-problem.html)

RFraley

SetFocus problem
 
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



Henry[_4_]

SetFocus problem
 
RF,

after setting the focus try:
Me.Repaint

HTH
Henry

"RFraley" wrote in message
...
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





RFraley

SetFocus problem
 
Thanks for the response Henry, but this did not change the end result.

Ralph

"Henry" wrote in message
...
RF,

after setting the focus try:
Me.Repaint

HTH
Henry

"RFraley" wrote in message
...
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








All times are GMT +1. The time now is 10:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com