ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Textbox/Userform question (https://www.excelbanter.com/excel-programming/326052-textbox-userform-question.html)

Stuart[_21_]

Textbox/Userform question
 
If I show a form which has 3 crucial textboxes that must
have user data in them.....can I return them to an empty
textbox before they are permitted to exit?

Maybe something like Select Case?

Regards.



Mark Bigelow

Textbox/Userform question
 
Try:

If textbox1.value = "" Then
textbox1.setfocus
Exit Sub
ElseIf textbox2.value = "" Then
textbox2.setfocus
Exit Sub
ElseIf textbox3.value = "" Then
textbox3.setfocus
Exit Sub
End If

Let me know if you have any problems.

Mark

Stuart wrote:
If I show a form which has 3 crucial textboxes that must
have user data in them.....can I return them to an empty
textbox before they are permitted to exit?

Maybe something like Select Case?

Regards.



Bob Phillips[_6_]

Textbox/Userform question
 
The command to 'activate' a textbox is SetFocus.

Also look at the SelStart and SelLength properties as well to make it even
nicer.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Stuart" wrote in message
...
If I show a form which has 3 crucial textboxes that must
have user data in them.....can I return them to an empty
textbox before they are permitted to exit?

Maybe something like Select Case?

Regards.





Stuart[_21_]

Textbox/Userform question
 
Many thanks to you both.

Why, when the user is returned to the textbox, does the form not display
"from the top"?
(Presumably SetFocus controls this action, thus the textbox in question is
displayed top left in the window).
Can I display the form from the top, by default?

Regards.

"Mark Bigelow" wrote in message
oups.com...
Try:

If textbox1.value = "" Then
textbox1.setfocus
Exit Sub
ElseIf textbox2.value = "" Then
textbox2.setfocus
Exit Sub
ElseIf textbox3.value = "" Then
textbox3.setfocus
Exit Sub
End If

Let me know if you have any problems.

Mark

Stuart wrote:
If I show a form which has 3 crucial textboxes that must
have user data in them.....can I return them to an empty
textbox before they are permitted to exit?

Maybe something like Select Case?

Regards.






All times are GMT +1. The time now is 12:33 AM.

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