Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a userform with a textbox and the following in the AfterUpdate event: If Not IsNumeric(Me.txtBill.Value) Then MsgBox "This needs to be a number", vbExclamation, "Input Error" Me.txtBill.Value = "" Me.txtBill.SetFocus However this does not set the focus back to the txtBill What am I doing wrong? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks - works a treat!
"Beto" wrote in message ... Newbie wrote: Hi, I have a userform with a textbox and the following in the AfterUpdate event: If Not IsNumeric(Me.txtBill.Value) Then MsgBox "This needs to be a number", vbExclamation, "Input Error" Me.txtBill.Value = "" Me.txtBill.SetFocus However this does not set the focus back to the txtBill You should put your code in the BeforeUpdate event and set Cancel to TRUE if the condition of exit is not met. Ex: Private Sub txtBill_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) If Not IsNumeric(Me.txtBill.Value) Then MsgBox "This needs to be a number", vbExclamation, "Input Error" Me.txtBill.Value = "" Cancel = True End If End Sub Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Newbie wrote:
Hi, I have a userform with a textbox and the following in the AfterUpdate event: If Not IsNumeric(Me.txtBill.Value) Then MsgBox "This needs to be a number", vbExclamation, "Input Error" Me.txtBill.Value = "" Me.txtBill.SetFocus However this does not set the focus back to the txtBill You should put your code in the BeforeUpdate event and set Cancel to TRUE if the condition of exit is not met. Ex: Private Sub txtBill_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean) If Not IsNumeric(Me.txtBill.Value) Then MsgBox "This needs to be a number", vbExclamation, "Input Error" Me.txtBill.Value = "" Cancel = True End If End Sub Regards, -- Beto Reply: Erase between the dot (inclusive) and the @. Responder: Borra la frase obvia y el punto previo. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
COMBO BOX FOCUS | Excel Worksheet Functions | |||
focus | Excel Discussion (Misc queries) | |||
set focus | Excel Discussion (Misc queries) | |||
Focus | Excel Worksheet Functions | |||
set focus | Excel Programming |