Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Colon at the end of excel file name(ex: problem.xls:1, problem.xls | New Users to Excel | |||
Started out as an Access problem. Now an Excel problem | Excel Discussion (Misc queries) | |||
SetFocus on a different sheet in VBA | Excel Discussion (Misc queries) | |||
SetFocus method in VBA | Excel Programming | |||
TextBox.SetFocus | Excel Programming |