ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Text Box on User Form Set Focus Issue (https://www.excelbanter.com/excel-programming/276256-text-box-user-form-set-focus-issue.html)

John Flynn

Text Box on User Form Set Focus Issue
 
I have a form with some text boxes used to capture some
text input. After the input box is updated I test the
value in a Function called DataOwnerNameValid. If I fail
the validation test I give the user a message. I then want
to return the cursor to the Input box so the user can
reenter the data. To do this I use the following command:

DataOwnerForm.DataOwnerInputBox.SetFocus

But it doesn't work. The next input box or other control
on the form is selected. What is the right way to do this?

Thank you

Private Sub DataOwnerInputBox_AfterUpdate()
If DataOwnerForm.DataOwnerInputBox = "" Then Exit Sub
OwnerOK = DataOwnerNameValid
(DataOwnerForm.DataOwnerInputBox)
If OwnerOK = False Then
MsgBox "Not Valid Name", vbExclamation, "Data
Owner Name Invalid"
DataOwnerForm.DataOwnerInputBox.SetFocus
End If
End Sub


All times are GMT +1. The time now is 03:45 PM.

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