Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

exclude comma's in text fields

Status
Not open for further replies.

barra47

Programmer
Dec 25, 2002
86
AU
is there a way of stopping users from entering a comma in to a text field or Memo field.

Thanks in advance
 
If access 2k or above you may consider the Replace function:
Me![name of TextBox].Value = Replace(Me![name of TextBox].Value, ",", " ")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
If you're using a text box on a form, you can work with the KeyPress event, so:
Code:
Private Sub Test1_KeyPress(KeyAscii As Integer)
If KeyAscii = 44 Then
    Beep
    KeyAscii = 0
End If
End Sub
This will ding at anyone who tries to enter a comma into the text box. Of course, you can also use a select case (you can still use if, but select is more efficient than multiple if statements) statement and evaluate all sorts of values for KeyAscii.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top