ExcelBanter

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

Patrick C. Simonds

SetFocus question
 
Can someone tell me why this code does not return the focus to TextBox7

If Len(PhoneNum) = 1 Then 'Checks for a correct amount of numbers
MsgBox "Please enter a correct Phone Number"
TextBox7.SetFocus
End If

Rick Rothstein

SetFocus question
 
What does happen? Where is this code located at? Did you really mean =1?

--
Rick (MVP - Excel)


"Patrick C. Simonds" wrote in message
...
Can someone tell me why this code does not return the focus to TextBox7

If Len(PhoneNum) = 1 Then 'Checks for a correct amount of numbers
MsgBox "Please enter a correct Phone Number"
TextBox7.SetFocus
End If



ShaneDevenshire

SetFocus question
 
Hi,

Your code must be on the userform code sheet. Here is a typical block of
code to handle an incorrect or missing entry:

IF Len(me.txtPhone) <7 then
Beep
MsgBox "That is not a legal phone number."
me.txtPhone=""
me.txtPhone.SetFocut
Exit Sub
End IF

This would be attached to the OK button of your userform in many cases.
--
Thanks,
Shane Devenshire


"Patrick C. Simonds" wrote:

Can someone tell me why this code does not return the focus to TextBox7

If Len(PhoneNum) = 1 Then 'Checks for a correct amount of numbers
MsgBox "Please enter a correct Phone Number"
TextBox7.SetFocus
End If



All times are GMT +1. The time now is 11:28 AM.

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