philfer
08-27-2010, 02:27 PM
Hello,
I have a textbox on a userform with the following associated code :-
Private Sub txtAmount_AfterUpdate()
'error handling
On Error GoTo Err_txtAmount_AfterUpdate
'if the user types in an amount covert it to millions with 2dp
txtAmount.Value = Format(CDbl(FormatNumber(txtAmount.Text, 2)), "#,##0.00")
'error handling
Exit_txtAmount_AfterUpdate:
Exit Sub
Err_txtAmount_AfterUpdate:
MsgBox "Please ensure you are typing in a number"
Me.txtAmount.Text = ""
Me.txtAmount.SetFocus
Resume Exit_txtAmount_AfterUpdate
End Sub
but it doesnt set the focus on the control but moves onto to the next one
Does anyone know why not???
Thanks
Phil
I have a textbox on a userform with the following associated code :-
Private Sub txtAmount_AfterUpdate()
'error handling
On Error GoTo Err_txtAmount_AfterUpdate
'if the user types in an amount covert it to millions with 2dp
txtAmount.Value = Format(CDbl(FormatNumber(txtAmount.Text, 2)), "#,##0.00")
'error handling
Exit_txtAmount_AfterUpdate:
Exit Sub
Err_txtAmount_AfterUpdate:
MsgBox "Please ensure you are typing in a number"
Me.txtAmount.Text = ""
Me.txtAmount.SetFocus
Resume Exit_txtAmount_AfterUpdate
End Sub
but it doesnt set the focus on the control but moves onto to the next one
Does anyone know why not???
Thanks
Phil