View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Henry T Henry T is offline
external usenet poster
 
Posts: 3
Default SetFocus not working

Hi,

I'm doing an invalid entry checking on a textbox, and in the event there's
really an invalid entry, after the MsgBox popped up, I'd like the textbox to
be get focus and its content highlighted.

Everything runs fine except the SetFocus part. No VBA error, it's just that
after the MsgBox, the focus is simply on the next control in my UserForm. The
SetFocus seems to be doing nothing. Could someone help?

code:
--------------------------------------------------------------------------------
Private Sub tbxTotalStoresSales_AfterUpdate()

If IsNumeric(ufInsertSales.tbxTotalStoresSales.Value) = False Then
MsgBox "Invalid Entry! Numeric Values Only. Please try again.", _
vbOKOnly + vbExclamation, "Attention!"
ufInsertSales.tbxTotalStoresSales.SetFocus
ElseIf ufInsertSales.tbxTotalStoresSales.Value < 0 Then
MsgBox "Invalid Entry! Negative Values Unacceptable. _
Please try again.", vbOKOnly + vbExclamation, "Attention!"
ufInsertSales.tbxTotalStoresSales.SetFocus
Else
tbxTotalStoresSales.Value = FormatCurrency(tbxTotalStoresSales.Value)
End If

End Sub
--------------------------------------------------------------------------------

Thank you,

Henry T