Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Mali Jainukul   on Sep 20 In MS Office Category.

  
Question Answered By: Raymond Fischer   on Sep 20

I think if you use the keypress, like example below, it will give you
what you want.

Private Sub txtAcctNum_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
MsgBox ("Please enter numbers only")
End If
End Sub

Or AfterUpdate might better meet your needs, see below for an
example:

Private Sub txtAcctNum_AfterUpdate()
Dim hold As Integer
If Len(txtAcctNum) > 5 Then
MsgBox ("Account Number can not exceed 5 digits")
End If
End Sub

Share: 

 

This Question has 7 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How to detect user modification of textboxes on a form? Or get search suggestion and latest updates.


Tagged: