I don't want any spaces

  • Thread starter Thread starter Mazza
  • Start date Start date
M

Mazza

Hi Guys,
Is there a way to enforce users to not leave spaces in a number field. I
have a lot of people using a database that has a 9 to 10 number field and
people keep putting spaces although a help screen tells them not to (Some
people never learn or read help)

Thanks in anticipation

Jan T
 
In the KeyPress event procedure of the text box ...

Private Sub TestText_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeySpace Then KeyAscii = 0
End Sub

Note that Access will not actually permit users to enter a space in a number
field. If they try, it will raise the error 'The value you entered isn't
valid for this field'. If your users can enter spaces in the field it is not
a number field.
 
Thanks Brendon this will help me heaps




Brendan Reynolds said:
In the KeyPress event procedure of the text box ...

Private Sub TestText_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeySpace Then KeyAscii = 0
End Sub

Note that Access will not actually permit users to enter a space in a
number field. If they try, it will raise the error 'The value you entered
isn't valid for this field'. If your users can enter spaces in the field
it is not a number field.
 
Back
Top