ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Focus (https://www.excelbanter.com/excel-programming/378675-focus.html)

[email protected]

Focus
 
I have a textbox for putting in Employee ID. The moment I enter the
employee ID and tab out of the control, there is a validation being
done. If it is an invalid ID, I get the message box but the curor moves
to the next control. How can I take it back?

If Len(aEmpID.Value) < 5 Or Not IsNumeric(aEmpID.Value) Or check =
False Then
MsgBox "Incorrect Employee ID"
aEmpID = Empty
aEmpID.SetFocus
End If

SetFocus is not working for me. Is there any other syntax?


[email protected]

Focus
 
Assuming that this code is in an Exit event procedu

Cancel = True ''replace aEmpID.SetFocus with this

Regards,
Steve
www.stkomp.com

wrote:
I have a textbox for putting in Employee ID. The moment I enter the
employee ID and tab out of the control, there is a validation being
done. If it is an invalid ID, I get the message box but the curor moves
to the next control. How can I take it back?

If Len(aEmpID.Value) < 5 Or Not IsNumeric(aEmpID.Value) Or check =
False Then
MsgBox "Incorrect Employee ID"
aEmpID = Empty
aEmpID.SetFocus
End If

SetFocus is not working for me. Is there any other syntax?



[email protected]

Focus
 
I had it in the AfterUpdate event but now I have changed it to Exit
even and your Cancel=True is working fine

Thank you


wrote:
Assuming that this code is in an Exit event procedu

Cancel = True ''replace aEmpID.SetFocus with this

Regards,
Steve
www.stkomp.com

wrote:
I have a textbox for putting in Employee ID. The moment I enter the
employee ID and tab out of the control, there is a validation being
done. If it is an invalid ID, I get the message box but the curor moves
to the next control. How can I take it back?

If Len(aEmpID.Value) < 5 Or Not IsNumeric(aEmpID.Value) Or check =
False Then
MsgBox "Incorrect Employee ID"
aEmpID = Empty
aEmpID.SetFocus
End If

SetFocus is not working for me. Is there any other syntax?




All times are GMT +1. The time now is 02:23 AM.

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